Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
gamerforEA committed May 9, 2019
1 parent a41e56b commit cf37a0c
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
package com.gamerforea.ttinkerer;

import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;
import net.minecraftforge.common.util.Constants;
import thaumic.tinkerer.common.lib.LibMisc;

public final class NoDupeProperties implements IExtendedEntityProperties
{
public static final String PROP_NAME = LibMisc.MOD_ID + "_NoDupeData";
private boolean denyDropAspect;

@Override
public void saveNBTData(NBTTagCompound compound)
{
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("DenyDropAspect", this.denyDropAspect);
compound.setTag(PROP_NAME, nbt);
}

@Override
public void loadNBTData(NBTTagCompound compound)
{
if (compound.hasKey(PROP_NAME, Constants.NBT.TAG_COMPOUND))
{
NBTTagCompound nbt = compound.getCompoundTag(PROP_NAME);
this.denyDropAspect = nbt.getBoolean("DenyDropAspect");
}
}

@Override
public void init(Entity entity, World world)
{
}

public static boolean canDropAspect(Entity entity)
{
NoDupeProperties prop = (NoDupeProperties) entity.getExtendedProperties(PROP_NAME);
return prop == null || !prop.denyDropAspect;
}

public static void denyDropAspect(Entity entity)
{
NoDupeProperties prop = (NoDupeProperties) entity.getExtendedProperties(PROP_NAME);
if (prop == null)
entity.registerExtendedProperties(PROP_NAME, prop = new NoDupeProperties());
prop.denyDropAspect = true;
}
}
package com.gamerforea.ttinkerer.properties;

import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;
import net.minecraftforge.common.util.Constants;
import thaumic.tinkerer.common.lib.LibMisc;

public final class NoDupeProperties implements IExtendedEntityProperties
{
private static final String PROP_NAME = LibMisc.MOD_ID + "_NoDupeData";
private boolean denyDropAspect;

@Override
public void saveNBTData(NBTTagCompound compound)
{
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("DenyDropAspect", this.denyDropAspect);
compound.setTag(PROP_NAME, nbt);
}

@Override
public void loadNBTData(NBTTagCompound compound)
{
if (compound.hasKey(PROP_NAME, Constants.NBT.TAG_COMPOUND))
{
NBTTagCompound nbt = compound.getCompoundTag(PROP_NAME);
this.denyDropAspect = nbt.getBoolean("DenyDropAspect");
}
}

@Override
public void init(Entity entity, World world)
{
}

public static boolean canDropAspect(Entity entity)
{
NoDupeProperties prop = (NoDupeProperties) entity.getExtendedProperties(PROP_NAME);
return prop == null || !prop.denyDropAspect;
}

public static void denyDropAspect(Entity entity)
{
NoDupeProperties prop = (NoDupeProperties) entity.getExtendedProperties(PROP_NAME);
if (prop == null)
entity.registerExtendedProperties(PROP_NAME, prop = new NoDupeProperties());
prop.denyDropAspect = true;
}
}
17 changes: 9 additions & 8 deletions src/main/java/net/minecraft/entity/player/EntityPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.player.*;

import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;

public abstract class EntityPlayer extends EntityLivingBase implements ICommandSender
{
public static final String PERSISTED_NBT_TAG = "PlayerPersisted";
private HashMap<Integer, ChunkCoordinates> spawnChunkMap = new HashMap<Integer, ChunkCoordinates>();
private HashMap<Integer, Boolean> spawnForcedMap = new HashMap<Integer, Boolean>();
private HashMap<Integer, ChunkCoordinates> spawnChunkMap = new HashMap<>();
private HashMap<Integer, Boolean> spawnForcedMap = new HashMap<>();

/**
* Inventory of the player
Expand Down Expand Up @@ -730,11 +733,9 @@ public void addToPlayerScore(Entity p_70084_1_, int p_70084_2_)
else
this.addStat(StatList.mobKillsStat, 1);

Iterator iterator = collection.iterator();

while (iterator.hasNext())
for (Object aCollection : collection)
{
ScoreObjective scoreobjective = (ScoreObjective) iterator.next();
ScoreObjective scoreobjective = (ScoreObjective) aCollection;
Score score = this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective);
score.func_96648_a();
}
Expand Down Expand Up @@ -1346,7 +1347,7 @@ public void attackTargetEntityWithCurrentItem(Entity p_71059_1_)
{
IEntityMultiPart ientitymultipart = ((EntityDragonPart) p_71059_1_).entityDragonObj;

if (ientitymultipart != null && ientitymultipart instanceof EntityLivingBase)
if (ientitymultipart instanceof EntityLivingBase)
object = ientitymultipart;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/minecraft/potion/PotionEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public PotionEffect(int p_i1576_1_, int p_i1576_2_, int p_i1576_3_, boolean p_i1
this.duration = p_i1576_2_;
this.amplifier = p_i1576_3_;
this.isAmbient = p_i1576_4_;
this.curativeItems = new ArrayList<ItemStack>();
this.curativeItems = new ArrayList<>();
this.curativeItems.add(new ItemStack(Items.milk_bucket));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase e
public void onBlockPreDestroy(World par1World, int par2, int par3, int par4, int par5)
{
TileEntity tile = par1World.getTileEntity(par2, par3, par4);
if (tile != null && tile instanceof TileEntityMobilizer)
if (tile instanceof TileEntityMobilizer)
((TileEntityMobilizer) tile).dead = true;
super.onBlockPreDestroy(par1World, par2, par3, par4, par5);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ public void readCustomNBT(NBTTagCompound par1NBTTagCompound)

public void writeCustomNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setIntArray(TAG_LEVELS, ArrayUtils.toPrimitive(this.levels.toArray(new Integer[this.levels.size()])));
par1NBTTagCompound.setIntArray(TAG_LEVELS, ArrayUtils.toPrimitive(this.levels.toArray(new Integer[0])));

par1NBTTagCompound.setIntArray(TAG_ENCHANTS, ArrayUtils.toPrimitive(this.enchantments.toArray(new Integer[this.enchantments.size()])));
par1NBTTagCompound.setIntArray(TAG_ENCHANTS, ArrayUtils.toPrimitive(this.enchantments.toArray(new Integer[0])));

NBTTagCompound totalAspectsCmp = new NBTTagCompound();
this.totalAspects.writeToNBT(totalAspectsCmp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,11 @@ int drawEssentia()
if (!ic.canOutputTo(orientation.getOpposite()))
return 0;

for (Aspect aspect : repairValues.keySet())
for (Map.Entry<Aspect, Integer> entry : repairValues.entrySet())
{
Aspect aspect = entry.getKey();
if (ic.getSuctionType(orientation.getOpposite()) == aspect && ic.getSuctionAmount(orientation.getOpposite()) < this.getSuctionAmount(orientation) && ic.takeEssentia(aspect, 1, orientation.getOpposite()) == 1)
return repairValues.get(aspect);
return entry.getValue();
}
}
return 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package thaumic.tinkerer.common.block.tile;

import com.gamerforea.ttinkerer.EventConfig;
import com.gamerforea.ttinkerer.NoDupeProperties;
import com.gamerforea.ttinkerer.properties.NoDupeProperties;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
Expand All @@ -27,7 +27,7 @@ public void updateEntity()
return;
for (int radius = 1; radius < 6; radius++)
{
ArrayList<TileEntity> pedestals = new ArrayList<TileEntity>();
ArrayList<TileEntity> pedestals = new ArrayList<>();
for (int x = this.xCoord - radius; x < this.xCoord + radius; x++)
{
for (int z = this.zCoord - radius; z < this.zCoord + radius; z++)
Expand All @@ -50,7 +50,7 @@ public void updateEntity()

if (ped1 != ped2 && ped2 != ped3 && ped1 != ped3)
{
ArrayList<Aspect> aspects = new ArrayList<Aspect>();
ArrayList<Aspect> aspects = new ArrayList<>();
aspects.add(ItemMobAspect.getAspect(ped1.getStackInSlot(0)));

aspects.add(ItemMobAspect.getAspect(ped2.getStackInSlot(0)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ContainerIchorPouch(EntityPlayer player)
{
((InventoryIchorPouch) this.inv).stackList = ((ItemFocusPouch) this.pouch.getItem()).getInventory(this.pouch);
}
catch (Exception e)
catch (Exception ignored)
{
}
}
Expand Down Expand Up @@ -140,6 +140,7 @@ public void onContainerClosed(EntityPlayer par1EntityPlayer)
// TODO gamerforEA add condition [2]
if (this.player == null || !this.canInteractWith(this.player))
return;

if (this.player.getHeldItem() != null && this.player.getHeldItem().isItemEqual(this.pouch))
this.player.setCurrentItemOrArmor(0, this.pouch);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ else if (!this.isBreaking)
{
ForgeEventFactory.onPlayerInteract(this.player, Action.RIGHT_CLICK_AIR, coords.posX, coords.posY, coords.posZ, side, this.worldObj);
Entity entity = this.detectedEntities.isEmpty() ? null : this.detectedEntities.get(this.worldObj.rand.nextInt(this.detectedEntities.size()));
done = entity != null && entity instanceof EntityLiving && (item.itemInteractionForEntity(stack, this.player, (EntityLivingBase) entity) || !(entity instanceof EntityAnimal) || ((EntityAnimal) entity).interact(this.player));
done = entity instanceof EntityLiving && (item.itemInteractionForEntity(stack, this.player, (EntityLivingBase) entity) || !(entity instanceof EntityAnimal) || ((EntityAnimal) entity).interact(this.player));

if (!done)
{
Expand All @@ -223,11 +223,12 @@ else if (!this.isBreaking)
catch (Throwable e)
{
e.printStackTrace();
List list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(this.xCoord - 8, this.yCoord - 8, this.zCoord - 8, this.xCoord + 8, this.yCoord + 8, this.zCoord + 8));
for (Object player : list)
@SuppressWarnings("unchecked")
List<? extends EntityPlayer> list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(this.xCoord - 8, this.yCoord - 8, this.zCoord - 8, this.xCoord + 8, this.yCoord + 8, this.zCoord + 8));
for (EntityPlayer player : list)
{
((EntityPlayer) player).addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Something went wrong with a Tool Dynamism Tablet! Check your FML log."));
((EntityPlayer) player).addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "" + EnumChatFormatting.ITALIC + e.getMessage()));
player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Something went wrong with a Tool Dynamism Tablet! Check your FML log."));
player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "" + EnumChatFormatting.ITALIC + e.getMessage()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package thaumic.tinkerer.common.block.tile.transvector;

import com.gamerforea.ttinkerer.EventConfig;
import com.google.common.collect.Sets;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
Expand All @@ -39,7 +39,7 @@
public class TileTransvectorDislocator extends TileTransvector
{
// TODO gamerforEA code start
private static final Set<Block> BLOCKS_BLACKLIST = Sets.newHashSet(Blocks.redstone_wire, Blocks.unpowered_comparator, Blocks.powered_comparator, Blocks.unpowered_repeater, Blocks.powered_repeater, Blocks.wooden_door, Blocks.iron_door);
private static final Set<Block> BLOCKS_BLACKLIST = ImmutableSet.of(Blocks.redstone_wire, Blocks.unpowered_comparator, Blocks.powered_comparator, Blocks.unpowered_repeater, Blocks.powered_repeater, Blocks.wooden_door, Blocks.iron_door);
// TODO gamerforEA code end

private static final String TAG_ORIENTATION = "orientation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public int tickRate(World par1World)
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
TileEntity tile = par1World.getTileEntity(par2, par3, par4);
if (tile != null && tile instanceof TileTransvectorDislocator)
if (tile instanceof TileTransvectorDislocator)
{
TileTransvectorDislocator dislocator = (TileTransvectorDislocator) tile;
dislocator.receiveRedstonePulse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ public void onFall(LivingFallEvent event)
int shockwave = EnchantmentHelper.getEnchantmentLevel(LibEnchantIDs.shockwave, boots);
if (shockwave > 0)
for (EntityLivingBase target : (List<EntityLivingBase>) event.entity.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(event.entity.posX - 10, event.entity.posY - 10, event.entity.posZ - 10, event.entity.posX + 10, event.entity.posY + 10, event.entity.posZ + 10)))
// TODO gamerforEA add condition [3]
{
// TODO gamerforEA add condition [3]
if (target != event.entity && event.distance > 3 && !EventUtils.cantDamage(event.entity, target))
target.attackEntityFrom(DamageSource.fall, .1F * shockwave * event.distance);
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/thaumic/tinkerer/common/item/ItemBloodSword.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package thaumic.tinkerer.common.item;

import com.gamerforea.ttinkerer.NoDupeProperties;
import com.gamerforea.ttinkerer.properties.NoDupeProperties;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
Expand Down Expand Up @@ -127,12 +127,14 @@ public void onDrops(LivingDropsEvent event)
//if(as!=null && as.size()!=0){
if (aspects != null)
{
// TODO gamerforEA code start
// TODO gamerforEA code replace, old code:
// event.drops.removeAll(event.drops);
if (event.entityLiving != null && !NoDupeProperties.canDropAspect(event.entityLiving))
return;

event.drops.clear();
// TODO gamerforEA code end

event.drops.removeAll(event.drops);
//for(Aspect a:as.getAspects()){
for (Aspect a : aspects)
{
Expand Down Expand Up @@ -172,7 +174,7 @@ public void onDamageTaken(LivingAttackEvent event)
if (handle)
{
Entity source = event.source.getSourceOfDamage();
if (source != null && source instanceof EntityLivingBase)
if (source instanceof EntityLivingBase)
{
EntityLivingBase attacker = (EntityLivingBase) source;
ItemStack itemInUse = attacker.getHeldItem();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/thaumic/tinkerer/common/item/ItemShareBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public boolean shouldDisplayInTab()
@Override
public IRegisterableResearch getResearchItem()
{
IRegisterableResearch research = (TTResearchItem) new TTResearchItem(LibResearch.KEY_SHARE_TOME, new AspectList(), 0, -1, 0, new ItemStack(this)).setStub().setAutoUnlock().setRound();
TTResearchItem research = (TTResearchItem) new TTResearchItem(LibResearch.KEY_SHARE_TOME, new AspectList(), 0, -1, 0, new ItemStack(this)).setStub().setAutoUnlock().setRound();
if (ConfigHandler.enableSurvivalShareTome)
((TTResearchItem) research).setPages(new ResearchPage("0"), ResearchHelper.recipePage(LibResearch.KEY_SHARE_TOME));
research.setPages(new ResearchPage("0"), ResearchHelper.recipePage(LibResearch.KEY_SHARE_TOME));
else
((TTResearchItem) research).setPages(new ResearchPage("0"));
research.setPages(new ResearchPage("0"));
return research;
}

Expand Down Expand Up @@ -131,7 +131,7 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla

private List<String> getPlayerResearch(ItemStack par1ItemStack)
{
List<String> retVals = new ArrayList<String>();
List<String> retVals = new ArrayList<>();
NBTTagCompound cmp = ItemNBTHelper.getNBT(par1ItemStack);
if (!cmp.hasKey("research"))
return retVals;
Expand Down
Loading

0 comments on commit cf37a0c

Please sign in to comment.