Merge branch 'master' into weaponry

Conflicts:
	src/main/java/tconstruct/tools/TinkerTools.java
This commit is contained in:
Bernhard Bonigl committed 2014-10-14 23:20:38 +02:00
commit f1ec9f24da
15 files changed
+190 -102

No files matched your search

@@ -40,7 +40,7 @@ public class TinkerArmorEvents
return;
}
String entityName = event.entityLiving.getClass().getSimpleName().toLowerCase();
if (entityName.contains("entitynpc"))
if (entityName.contains("entitynpc") || entityName.contains("entitycustomnpc"))
return;
int count = event.entityLiving instanceof EntityDragon ? 5 : 1;
@@ -16,7 +16,6 @@ public class ModifyBuilder
if (copy.getItem() instanceof IModifyable)
{
IModifyable item = (IModifyable) copy.getItem();
NBTTagCompound tags = input.getTagCompound().getCompoundTag(item.getBaseTagName());
boolean built = false;
for (ItemModifier mod : itemModifiers)
@@ -32,60 +32,42 @@ public abstract class AOEHarvestTool extends HarvestTool {
if(block == null || !isEffective(block, meta))
return super.onBlockStartBreak(stack, x,y,z, player);
boolean originalBlock = true;
// check if we're breaking the block we hit, or if this call belongs to one of the surrounding blocks broken by the AOE
if(player.worldObj.isRemote)
{
originalBlock = Minecraft.getMinecraft().playerController.sameToolAndBlock(x,y,z);
}
// same check serverside
else {
ItemInWorldManager iiiwm = ((EntityPlayerMP) player).theItemInWorldManager;
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(player.worldObj, player, false, 4.5d);
if(mop == null)
return super.onBlockStartBreak(stack, x,y,z, player);
int sideHit = mop.sideHit;
//int sideHit = Minecraft.getMinecraft().objectMouseOver.sideHit;
if(x != iiiwm.partiallyDestroyedBlockX || y != iiiwm.partiallyDestroyedBlockY || z != iiiwm.partiallyDestroyedBlockZ)
originalBlock = false;
}
// the code below initiates block breaks, which again call this function. But we don't want to do the aoe-break-stuff again. This is to prevent recursive, infinite-range aoe blockbreaking.
if(originalBlock || player.capabilities.isCreativeMode) {
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(player.worldObj, player, false, 4.5d);
if(mop == null)
return super.onBlockStartBreak(stack, x,y,z, player);
int sideHit = mop.sideHit;
//int sideHit = Minecraft.getMinecraft().objectMouseOver.sideHit;
// we successfully destroyed a block. time to do AOE!
int xRange = breakRadius;
int yRange = breakRadius;
int zRange = breakDepth;
switch (sideHit) {
case 0:
case 1:
yRange = breakDepth;
zRange = breakRadius;
break;
case 2:
case 3:
xRange = breakRadius;
zRange = breakDepth;
break;
case 4:
case 5:
xRange = breakDepth;
zRange = breakRadius;
break;
}
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
for (int zPos = z - zRange; zPos <= z + zRange; zPos++) {
// don't break the originally already broken block, duh
if (xPos == x && yPos == y && zPos == z)
continue;
breakExtraBlock(player.worldObj, xPos, yPos, zPos, sideHit, player, x,y,z);
}
// we successfully destroyed a block. time to do AOE!
int xRange = breakRadius;
int yRange = breakRadius;
int zRange = breakDepth;
switch (sideHit) {
case 0:
case 1:
yRange = breakDepth;
zRange = breakRadius;
break;
case 2:
case 3:
xRange = breakRadius;
zRange = breakDepth;
break;
case 4:
case 5:
xRange = breakDepth;
zRange = breakRadius;
break;
}
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
for (int zPos = z - zRange; zPos <= z + zRange; zPos++) {
// don't break the originally already broken block, duh
if (xPos == x && yPos == y && zPos == z)
continue;
breakExtraBlock(player.worldObj, xPos, yPos, zPos, sideHit, player, x,y,z);
}
return super.onBlockStartBreak(stack, x, y, z, player);
@@ -78,8 +78,7 @@ public class DynamicToolPart extends CraftingItem implements IToolPart
// general name
else
{
material = StatCollector.translateToLocal("material." + material);
return StatCollector.translateToLocal("toolpart." + partName).replaceAll("%%material", material);
return StatCollector.translateToLocal("toolpart." + partName).replaceAll("%%material", toolmat.prefixName());
}
}
@@ -1,5 +1,7 @@
package tconstruct.library.tools;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
@@ -10,10 +12,12 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import tconstruct.TConstruct;
import tconstruct.util.config.PHConstruct;
/* Base class for tools that should be harvesting blocks */
@@ -256,11 +260,19 @@ public abstract class HarvestTool extends ToolCore
}
// server sided handling
if (!world.isRemote) {
// serverside we
EntityPlayerMP mpPlayer = (EntityPlayerMP) player;
// serverside we reproduce ItemInWorldManager.tryHarvestBlock
mpPlayer.theItemInWorldManager.tryHarvestBlock(x, y, z);
// send block update to client
// ItemInWorldManager.removeBlock
block.onBlockHarvested(world, x,y,z, meta, player);
if(block.removedByPlayer(world, player, x,y,z, true)) // boolean is if block can be harvested, checked above
{
block.onBlockDestroyedByPlayer( world, x,y,z, meta);
block.harvestBlock(world, player, x,y,z, meta);
}
// always send block update to client
EntityPlayerMP mpPlayer = (EntityPlayerMP) player;
mpPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
}
// client sided handling
@@ -268,7 +280,18 @@ public abstract class HarvestTool extends ToolCore
PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController;
// clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send any new packets
// the code above, executed on the server, sends a block-updates that give us the correct state of the block we destroy.
// following code can be found in PlayerControllerMP.onPlayerDestroyBlock
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
if(block.removedByPlayer(world, player, x,y,z))
{
block.onBlockDestroyedByPlayer(world, x,y,z, meta);
}
pcmp.onPlayerDestroyBlock(x, y, z, sidehit);
// send an update to the server, so we get an update back
if(PHConstruct.extraBlockUpdates)
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit));
}
}
}
@@ -758,6 +758,8 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IMo
int max = getMaxEnergyStored(stack);
if(energy > 0) {
int damage = ((max - energy) * 100) / max;
if(damage == 0 && max-energy > 0)
damage = 1;
super.setDamage(stack, damage);
return damage;
}
@@ -1,34 +1,50 @@
package tconstruct.smeltery;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.registry.*;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;
import java.util.*;
import mantle.blocks.BlockUtils;
import mantle.blocks.abstracts.MultiServantLogic;
import mantle.pulsar.pulse.*;
import mantle.pulsar.pulse.Handler;
import mantle.pulsar.pulse.Pulse;
import net.minecraft.block.Block;
import net.minecraft.block.material.*;
import net.minecraft.init.*;
import net.minecraft.item.*;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialLiquid;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.*;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.oredict.*;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import tconstruct.TConstruct;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.*;
import tconstruct.library.crafting.FluidType;
import tconstruct.library.crafting.LiquidCasting;
import tconstruct.library.crafting.Smeltery;
import tconstruct.library.util.IPattern;
import tconstruct.smeltery.blocks.*;
import tconstruct.smeltery.itemblocks.*;
import tconstruct.smeltery.items.*;
import tconstruct.smeltery.items.FilledBucket;
import tconstruct.smeltery.items.MetalPattern;
import tconstruct.smeltery.logic.*;
import tconstruct.tools.TinkerTools;
import tconstruct.util.config.PHConstruct;
import tconstruct.world.TinkerWorld;
import java.util.*;
@ObjectHolder(TConstruct.modID)
@Pulse(id = "Tinkers' Smeltery", description = "Liquid metals, casting, and the multiblock structure.")
public class TinkerSmeltery
@@ -940,10 +956,18 @@ public class TinkerSmeltery
// Buckets
ItemStack bucket = new ItemStack(Items.bucket);
Item thermalBucket = GameRegistry.findItem("ThermalFoundation", "bucket");
for (int sc = 0; sc < 26; sc++)
{
if (TinkerSmeltery.fluids[sc] != null)
tableCasting.addCastingRecipe(new ItemStack(TinkerSmeltery.buckets, 1, sc), new FluidStack(TinkerSmeltery.fluids[sc], FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10);
if (TinkerSmeltery.fluids[sc] != null) {
// TE support
if(fluids[sc] == TinkerSmeltery.moltenEnderFluid && thermalBucket != null)
// bucket of resonant ender instead of liquified ender
tableCasting.addCastingRecipe(new ItemStack(thermalBucket, 1, 2), new FluidStack(TinkerSmeltery.fluids[sc], FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10);
else
tableCasting.addCastingRecipe(new ItemStack(TinkerSmeltery.buckets, 1, sc), new FluidStack(TinkerSmeltery.fluids[sc], FluidContainerRegistry.BUCKET_VOLUME), bucket, true, 10);
}
}
// Clear glass pane casting
@@ -1077,11 +1101,11 @@ public class TinkerSmeltery
protected static void addRecipesForSmeltery ()
{
// Smeltery fuels
Smeltery.addSmelteryFuel(FluidRegistry.LAVA, 1300, 12); // lava lasts 4 seconds per 15 mb
Smeltery.addSmelteryFuel(FluidRegistry.LAVA, 1300, 80); // lava lasts 4 seconds per 15 mb
// register pyrotheum if it's present
Fluid pyrotheum = FluidRegistry.getFluid("pyrotheum");
if (pyrotheum != null)
Smeltery.addSmelteryFuel(pyrotheum, 5000, 9); // pyrotheum lasts 3 seconds per 15 mb
Smeltery.addSmelteryFuel(pyrotheum, 5000, 70); // pyrotheum lasts 3.5 seconds per 15 mb
// BLOOD FOR THE BLOOD GOD
if (TinkerWorld.meatBlock != null)
@@ -293,25 +293,26 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
*/
if(validStructure)
if (tick % 4 == 0) {
if (tick % 4 == 0) {
if (useTime > 0)
useTime -= 4;
if(validStructure) {
checkHasItems();
// consume fuel if needed
if(useTime <= 0 && inUse)
updateFuelGague();
heatItems();
}
}
if (tick % 20 == 0)
{
if (!validStructure)
checkValidPlacement();
if (useTime > 0)
useTime -= 3;
if (validStructure && useTime <= 0 && inUse)
{
updateFuelGague();
}
if (needsUpdate)
{
needsUpdate = false;
@@ -600,10 +601,15 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
FluidStack liquid = tankContainer.drain(ForgeDirection.DOWN, 15, false);
if (liquid != null && Smeltery.isSmelteryFuel(liquid.getFluid())) // doublecheck that everything is ok
{
// drain actual liquid, non simulated
liquid = tankContainer.drain(ForgeDirection.DOWN, 15, true);
useTime += (int)((float)Smeltery.getFuelDuration(liquid.getFluid())*15f/(float)liquid.amount);
internalTemp = Smeltery.getFuelPower(liquid.getFluid());
do {
// drain actual liquid, non simulated
liquid = tankContainer.drain(ForgeDirection.DOWN, 15, true);
// we try to do it as long as we don't have enough. Only needed for rapid-use fuels.
if(liquid == null || liquid.amount == 0)
break;
useTime += (int) ((float) Smeltery.getFuelDuration(liquid.getFluid()) * Math.round(15f / (float) liquid.amount));
internalTemp = Smeltery.getFuelPower(liquid.getFluid());
} while(useTime < 0);
// update fuel display
updateFuelDisplay(); // this also ensures that the next fuel tank is displayed if this drain made the current one empty
@@ -25,7 +25,9 @@ public class ToolPart extends CraftingItem implements IToolPart
@Override
public String getItemStackDisplayName (ItemStack par1ItemStack)
{
String material = toolTextureNames[par1ItemStack.getItemDamage()];
String material = "";
if(par1ItemStack.getItemDamage() < toolTextureNames.length)
material = toolTextureNames[par1ItemStack.getItemDamage()];
String name = "";
if (StatCollector.canTranslate("toolpart." + partName + "." + material))
@@ -21,7 +21,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
public CraftingStationLogic()
{
super(17); // 9 for crafting, 1 for output, 6 for extensions, 1 for
super(10); // 9 for crafting, 1 for output, 6 for extensions, 1 for
// plans
}
@@ -1,6 +1,7 @@
package tconstruct.util;
import cpw.mods.fml.common.event.FMLInterModComms;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -10,6 +11,7 @@ import tconstruct.TConstruct;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.crafting.Smeltery;
import tconstruct.library.crafting.StencilBuilder;
import tconstruct.library.tools.DynamicToolPart;
import tconstruct.library.tools.ToolMaterial;
@@ -167,6 +169,56 @@ public final class IMCHandler {
TConstruct.logger.info("Casting IMC: Added fluid " + tag.getString("FluidName") + " to part casting");
}
else if(type.equals("addSmelteryMelting")) {
if (!message.isNBTMessage()) {
logInvalidMessage(message);
continue;
}
NBTTagCompound tag = message.getNBTValue();
if (!checkRequiredTags("Smeltery", tag, "FluidName", "Temperature", "Item", "Block"))
continue;
FluidStack liquid = FluidStack.loadFluidStackFromNBT(tag);
if(liquid == null) {
TConstruct.logger.error("Smeltery IMC: No fluid found");
continue;
}
if(liquid.amount <= 0) {
TConstruct.logger.error("Smeltery IMC: Liquid has to have an amount greater than zero");
continue;
}
ItemStack item = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Item"));
ItemStack block = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Block"));
int temperature = tag.getInteger("Temperature");
Smeltery.addMelting(item, Block.getBlockFromItem(block.getItem()), block.getItemDamage(), temperature, liquid);
TConstruct.logger.info("Smeltery IMC: Added melting: " + item.getDisplayName() + " to " + liquid.amount + "mb " + liquid.getLocalizedName());
}
else if(type.equals("addSmelteryFuel")) {
if (!message.isNBTMessage()) {
logInvalidMessage(message);
continue;
}
NBTTagCompound tag = message.getNBTValue();
if (!checkRequiredTags("Smeltery", tag, "FluidName", "Temperature", "Duration"))
continue;
FluidStack liquid = FluidStack.loadFluidStackFromNBT(tag);
if(liquid == null) {
TConstruct.logger.error("Smeltery IMC: No fluid found");
continue;
}
int temperature = tag.getInteger("Temperature");
int duration = tag.getInteger("Duration");
Smeltery.addSmelteryFuel(liquid.getFluid(), temperature, duration);
TConstruct.logger.info("Smeltery IMC: Added fuel: " + liquid.getLocalizedName() + " (" + temperature + ", " + duration + ")");
}
}
}
@@ -186,6 +186,7 @@ public class PHConstruct
newSmeltery = config.get("Experimental", "Use new adaptive Smeltery code", false, "Warning: Very buggy").getBoolean(false);
meltableHorses = config.get("Experimental", "Allow horses to be melted down for glue", true).getBoolean(true);
minimalTextures = config.get("Experimental", "Minimal Textures", false).getBoolean(false);
extraBlockUpdates = config.get("Experimental", "Send additional block updates when using AOE tools", true,"This fixes very fast tools sometimes resulting in ghost blocks, but causes a bit more network traffic. Should be fine in theory.").getBoolean(true);
/* Save the configuration file only if it has changed */
if (config.hasChanged())
@@ -355,5 +356,6 @@ public class PHConstruct
public static boolean newSmeltery;
public static boolean meltableHorses;
public static boolean minimalTextures;
public static boolean extraBlockUpdates;
}
@@ -1,6 +1,7 @@
package tconstruct.world.entity;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.EntitySenses;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.monster.*;
import net.minecraft.entity.player.EntityPlayer;
@@ -55,19 +56,12 @@ public class BlueSlime extends EntityLiving implements IMob, IBossDisplayData
super.damageEntity(damageSource, damage);
}
public String getEntityName ()
{
String s = EntityList.getEntityString(this);
if (s == null)
{
s = "generic";
}
@Override
public String getCommandSenderName() {
if (getSlimeSize() >= 8)
s = "TConstruct.KingSlime";
return StatCollector.translateToLocal("entity.TConstruct.KingSlime.name");
return StatCollector.translateToLocal("entity." + s + ".name");
return super.getCommandSenderName();
}
@Override
@@ -35,7 +35,7 @@ public class SlimeIslandGen extends WorldGenerator implements IWorldGenerator
// version
{
// dim 0 only?
if ((chunkGenerator instanceof ChunkProviderFlat || world.provider.terrainType == WorldType.FLAT) && PHConstruct.genIslandsFlat)
if ((chunkGenerator instanceof ChunkProviderFlat || world.provider.terrainType == WorldType.FLAT) && !PHConstruct.genIslandsFlat)
{
return;
}