adding 1.7.10 code

This commit is contained in:
kitsushadow
2016-12-10 10:31:21 -05:00
parent 1935947d54
commit e38396eb31
842 changed files with 54852 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
package com.kitsu.medievalcraft;
import com.kitsu.medievalcraft.entity.EntityCannonBall;
import com.kitsu.medievalcraft.entity.EntityITSpear;
import com.kitsu.medievalcraft.entity.EntityModelArrow;
import com.kitsu.medievalcraft.entity.EntityModelITArrow;
import com.kitsu.medievalcraft.entity.EntityShit;
import com.kitsu.medievalcraft.entity.EntityTester;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.renderer.RendererRegistry;
import com.kitsu.medievalcraft.renderer.blocks.RenderModelArrow;
import com.kitsu.medievalcraft.renderer.blocks.RenderModelITArrow;
import com.kitsu.medievalcraft.renderer.blocks.RenderModelITSpear;
import com.kitsu.medievalcraft.renderer.blocks.cannons.Render_CannonBall_Iron;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.world.World;
public class ClientProxy extends CommonProxy {
@Override
public void registerRenderer() {
RenderingRegistry.registerEntityRenderingHandler(EntityShit.class, new RenderSnowball(ModItems.itemShit));
RenderingRegistry.registerEntityRenderingHandler(EntityTester.class, new RenderSnowball(ModItems.itemTester));
RenderingRegistry.registerEntityRenderingHandler(EntityModelArrow.class, new RenderModelArrow());
RenderingRegistry.registerEntityRenderingHandler(EntityModelITArrow.class, new RenderModelITArrow());
RenderingRegistry.registerEntityRenderingHandler(EntityITSpear.class, new RenderModelITSpear());
RenderingRegistry.registerEntityRenderingHandler(EntityCannonBall.class, new Render_CannonBall_Iron());
//RenderingRegistry.registerEntityRenderingHandler(ProjectileCannonBall.class, new Render_CannonBall_Projectile());
}
@Override
public void registerItemRenderers() {
RenderId.init();
RendererRegistry.init();
}
@Override
public void registerSounds() {
//MinecraftForge.EVENT_BUS.register(new ModSounds());//register the sound event handling class
}
@Override
public Object getClient() {
return FMLClientHandler.instance().getClient();
}
@Override
public World getClientWorld() {
return FMLClientHandler.instance().getClient().theWorld;
}
}

View File

@@ -0,0 +1,47 @@
package com.kitsu.medievalcraft;
import net.minecraft.world.World;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
public class CommonProxy {
public void registerRenderer() {
}
public void registerItemRenderers() {
}
public void registerSounds() {
}
public Object getClient() {
return null;
}
public World getClientWorld() {
return null;
}
public void preInit(FMLPreInitializationEvent e) {
//ModItems.init();
//ModBlocks.init();
//ModCrafting.init();
}
public void init(FMLInitializationEvent e) {
}
public void postInit(FMLPostInitializationEvent e) {
}
}

View File

@@ -0,0 +1,149 @@
package com.kitsu.medievalcraft;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.compat.FuelHandler;
import com.kitsu.medievalcraft.compat.ModDict;
import com.kitsu.medievalcraft.crafting.CraftingHandle;
import com.kitsu.medievalcraft.crafting.ModCrafting;
import com.kitsu.medievalcraft.entity.EntityCannonBall;
import com.kitsu.medievalcraft.entity.EntityITSpear;
import com.kitsu.medievalcraft.entity.EntityModelArrow;
import com.kitsu.medievalcraft.entity.EntityModelITArrow;
import com.kitsu.medievalcraft.entity.EntityShit;
import com.kitsu.medievalcraft.entity.EntityShortLivedShit;
import com.kitsu.medievalcraft.entity.EntityTester;
import com.kitsu.medievalcraft.events.BucketHandle;
import com.kitsu.medievalcraft.events.EventHandle;
import com.kitsu.medievalcraft.gui.GuiHandler;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.packethandle.curedLeather.MsgHandleCuredLeatherX;
import com.kitsu.medievalcraft.packethandle.curedLeather.MsgHandleCuredLeatherY;
import com.kitsu.medievalcraft.packethandle.curedLeather.MsgHandleCuredLeatherZ;
import com.kitsu.medievalcraft.packethandle.curedLeather.MsgPacketCuredLeatherX;
import com.kitsu.medievalcraft.packethandle.curedLeather.MsgPacketCuredLeatherY;
import com.kitsu.medievalcraft.packethandle.curedLeather.MsgPacketCuredLeatherZ;
import com.kitsu.medievalcraft.packethandle.forge.MsgHandleForge;
import com.kitsu.medievalcraft.packethandle.forge.MsgPacketForge;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgHandle;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgHandleLocX;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgHandleLocY;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgHandleLocZ;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgPacket;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgPacketLocX;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgPacketLocY;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgPacketLocZ;
import com.kitsu.medievalcraft.packethandle.sandFilterRender.MsgHandleSandFilterRender;
import com.kitsu.medievalcraft.packethandle.sandFilterRender.MsgPacketSandFilterRender;
import com.kitsu.medievalcraft.packethandle.shelf.MsgHandleShelfCase;
import com.kitsu.medievalcraft.packethandle.shelf.MsgPacketShelfCase;
import com.kitsu.medievalcraft.tileents.TileEntRegister;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
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.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import net.minecraftforge.common.MinecraftForge;
@Mod(modid = Main.MODID, name = Main.MODNAME, version = Main.VERSION)
public class Main {
public static final String MODID = "kitsumedievalcraft";
public static final String MODNAME = "ForgeCraft";
public static final String VERSION = "2.4.1";
public static SimpleNetworkWrapper sNet;
@Instance
public static Main instance = new Main();
@SidedProxy(clientSide="com.kitsu.medievalcraft.ClientProxy", serverSide="com.kitsu.medievalcraft.CommonProxy")
public static CommonProxy proxy;
/**
* Run before anything else. Read your config, create blocks, items, etc, and
* register them with the GameRegistry.
*/
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) {
this.proxy.preInit(e);
sNet = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
sNet.registerMessage(MsgHandle.class, MsgPacket.class, 1, Side.CLIENT);
sNet.registerMessage(MsgHandleLocX.class, MsgPacketLocX.class, 2, Side.CLIENT);
sNet.registerMessage(MsgHandleLocY.class, MsgPacketLocY.class, 3, Side.CLIENT);
sNet.registerMessage(MsgHandleLocZ.class, MsgPacketLocZ.class, 4, Side.CLIENT);
sNet.registerMessage(MsgHandleSandFilterRender.class, MsgPacketSandFilterRender.class, 5, Side.CLIENT);
sNet.registerMessage(MsgHandleCuredLeatherX.class, MsgPacketCuredLeatherX.class, 6, Side.SERVER);
sNet.registerMessage(MsgHandleCuredLeatherY.class, MsgPacketCuredLeatherY.class, 7, Side.SERVER);
sNet.registerMessage(MsgHandleCuredLeatherZ.class, MsgPacketCuredLeatherZ.class, 8, Side.SERVER);
sNet.registerMessage(MsgHandleShelfCase.class, MsgPacketShelfCase.class, 9, Side.SERVER);
sNet.registerMessage(MsgHandleForge.class, MsgPacketForge.class, 10, Side.SERVER);
//sNet.registerMessage(MsgHandleCannon.class, MsgPacketCannon.class, 11, Side.CLIENT);
//sNet.registerMessage(MsgHandleCannon.class, MsgPacketCannon.class, 12, Side.SERVER);
//sNet.registerMessage(MsgHandleCannonX.class, MsgPacketCannonX.class, 12, Side.CLIENT);
//sNet.registerMessage(MsgHandleCannonY.class, MsgPacketCannonY.class, 13, Side.CLIENT);
//sNet.registerMessage(MsgHandleCannonZ.class, MsgPacketCannonZ.class, 14, Side.CLIENT);
CustomTab.MedievalTab();
ModBlocks.init();
ModItems.init();
ModCrafting.init();
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
}
@Mod.EventHandler
public void init(FMLInitializationEvent e) {
this.proxy.init(e);
FMLCommonHandler.instance().bus().register(new CraftingHandle());
FMLCommonHandler.instance().bus().register(new EventHandle());
MinecraftForge.EVENT_BUS.register(BucketHandle.INSTANCE);
MinecraftForge.EVENT_BUS.register(new EventHandle());
MinecraftForge.EVENT_BUS.register(new CraftingHandle());
BucketHandle.INSTANCE.buckets.put(ModBlocks.blockFilteredWater, ModItems.filteredBucket);
BucketHandle.INSTANCE.buckets.put(ModBlocks.blockTannin, ModItems.tanninBucket);
BucketHandle.INSTANCE.buckets.put(ModBlocks.blockSlackedLime, ModItems.slackBucket);
EntityRegistry.registerModEntity(EntityShit.class, "itemShit", 1, this, 64, 10, true);
EntityRegistry.registerModEntity(EntityModelArrow.class, "itemModelArrow", 2, this, 64, 10, true);
EntityRegistry.registerModEntity(EntityModelITArrow.class, "itemIronTippedModelArrow", 3, this, 64, 10, true);
EntityRegistry.registerModEntity(EntityITSpear.class, "itemITSpear", 4, this, 64, 10, true);
EntityRegistry.registerModEntity(EntityTester.class, "itemTester", 5, this, 64, 10, true);
EntityRegistry.registerModEntity(EntityShortLivedShit.class, "itemShit", 6, this, 64, 10, true);
EntityRegistry.registerModEntity(EntityCannonBall.class, "cannonBall", 7, this, 64, 10, true);
//EntityRegistry.registerModEntity(ProjectileCannonBall.class, "cannonBallProjectile", 8, this, 64, 10, true);
GameRegistry.registerFuelHandler(new FuelHandler());
TileEntRegister.init();
}
/**
* Handle interaction with other mods, complete your setup based on this.
*/
@EventHandler
public void postInit(FMLPostInitializationEvent e) {
this.proxy.postInit(e);
this.proxy.registerRenderer();
this.proxy.registerItemRenderers();
this.proxy.registerSounds();
ModDict.RegisterOres();
System.out.println("U want some Body Massage?");
//RenderingRegistry.registerEntityRenderingHandler(EntityShit.class, new RenderSnowball(ModItems.itemShit));
}
}

View File

@@ -0,0 +1,260 @@
package com.kitsu.medievalcraft.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.cannon.CannonBallBlock28;
import com.kitsu.medievalcraft.block.cannon.Cannon_28;
import com.kitsu.medievalcraft.block.crucible.CrucibleIronIngot;
import com.kitsu.medievalcraft.block.crucible.CrucibleIronOre;
import com.kitsu.medievalcraft.block.crucible.CrucibleLapis;
import com.kitsu.medievalcraft.block.crucible.CrucibleRedstone;
import com.kitsu.medievalcraft.block.crucible.CrucibleWootz;
import com.kitsu.medievalcraft.block.crucible.empty.BoilingWaterCrucible;
import com.kitsu.medievalcraft.block.crucible.empty.EmptyCookedCrucible;
import com.kitsu.medievalcraft.block.crucible.empty.EmptySoftCrucible;
import com.kitsu.medievalcraft.block.crucible.empty.FilledWaterCrucible;
import com.kitsu.medievalcraft.block.crucible.empty.SlackWaterCrucible;
import com.kitsu.medievalcraft.block.crucible.empty.TanWaterCrucible;
import com.kitsu.medievalcraft.block.decorative.EggWashedBrick;
import com.kitsu.medievalcraft.block.decorative.EggWashedWall;
import com.kitsu.medievalcraft.block.decorative.LimestoneRaw;
import com.kitsu.medievalcraft.block.fluid.BlockFilteredWater;
import com.kitsu.medievalcraft.block.fluid.BlockSlackedLime;
import com.kitsu.medievalcraft.block.fluid.BlockSmoke;
import com.kitsu.medievalcraft.block.fluid.BlockTannin;
import com.kitsu.medievalcraft.block.ingots.DamascusIngot;
import com.kitsu.medievalcraft.block.ingots.Diamond;
import com.kitsu.medievalcraft.block.ingots.Emerald;
import com.kitsu.medievalcraft.block.ingots.IronPlate;
import com.kitsu.medievalcraft.block.ingots.LapisIngot;
import com.kitsu.medievalcraft.block.ingots.RedstoneIngot;
import com.kitsu.medievalcraft.block.ingots.RefinedIron;
import com.kitsu.medievalcraft.block.machines.Firebox;
import com.kitsu.medievalcraft.block.machines.Forge;
import com.kitsu.medievalcraft.block.machines.ForgeAnvil;
import com.kitsu.medievalcraft.block.machines.SolidFilter;
import com.kitsu.medievalcraft.block.machines.TestForge;
import com.kitsu.medievalcraft.block.machines.WaterFilter;
import com.kitsu.medievalcraft.block.machines.formTable;
import com.kitsu.medievalcraft.block.wood.ShelfFour;
import com.kitsu.medievalcraft.block.wood.SmallBarrel;
import com.kitsu.medievalcraft.block.wood.SmallBarrelLid;
import com.kitsu.medievalcraft.block.wood.clean.CleanAcacia;
import com.kitsu.medievalcraft.block.wood.clean.CleanBirch;
import com.kitsu.medievalcraft.block.wood.clean.CleanDarkOak;
import com.kitsu.medievalcraft.block.wood.clean.CleanJungle;
import com.kitsu.medievalcraft.block.wood.clean.CleanOak;
import com.kitsu.medievalcraft.block.wood.clean.CleanSpruce;
import com.kitsu.medievalcraft.block.wood.quartersplit.AcaciaSplitLog;
import com.kitsu.medievalcraft.block.wood.quartersplit.BirchSplitLog;
import com.kitsu.medievalcraft.block.wood.quartersplit.DarkSplitLog;
import com.kitsu.medievalcraft.block.wood.quartersplit.JungleSplitLog;
import com.kitsu.medievalcraft.block.wood.quartersplit.OakSplitLog;
import com.kitsu.medievalcraft.block.wood.quartersplit.SpruceSplitLog;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModBlocks {
//NEW INGOTS
public static Block refinedIron;
public static Block damascus;
public static Block ironPlate;
public static Block redstoneIngot;
public static Block lapisIngot;
//NEW CRUCIBLES
public static Block testBlock;
public static Block crucibleIronOre;
public static Block crucibleIronIngot;
public static Block crucibleWootz;
public static Block crucibleLapis;
public static Block crucibleRedstone;
//AESTHETIC
public static Block shitblock;
public static Block eggWashedWall;
public static Block eggWashedBrick;
public static Block wootzOre;
public static Block limestoneRaw;
//LIQUIDS
public static Block blockSmoke;
public static Block blockFilteredWater;
public static Fluid fluidFiltered;
public static Block blockTannin;
public static Fluid fluidTan;
public static Block blockSlackedLime;
public static Fluid fluidSlackedLime;
//WOODEN BLOCKS
public static Block cleanOak;
public static Block cleanAcacia;
public static Block cleanJungle;
public static Block cleanSpruce;
public static Block cleanBirch;
public static Block cleanDarkOak;
//SPLIT LOGS
public static Block acaciaSplitLog;
public static Block birchSplitLog;
public static Block darkSplitLog;
public static Block jungleSplitLog;
public static Block oakSplitLog;
public static Block spruceSplitLog;
public static Block smallBarrelLid;
public static Block smallBarrel;
//MACHINES
public static Block formtable;
//public static Block newForge;
//public static Block testForge;
public static Block forgeAnvil;
public static Block waterFilter;
public static Block shelfFour;
public static Block firebox;
public static Block solidFilter;
public static Block forge;
//CANNONS
public static Block cannon_28;
public static Block cannonBall_28;
//GEMS
public static Block myDiamond, myEmerald;
//IRON INGOTS
//public static Block myIronIngot, hotIronBlock;
//IRON PLATES
//public static Block ironPlate, hotIronPlate;
//DAMASCUS INGOTS
//public static Block damascusIngot, hotDamascusIngot;
//LAPIS INGOTS
//public static Block lapisIngot, hotLapisIngot;
//REDSTONE INGOTS
//public static Block redstoneIngot, hotRedstoneIngot;
//Empty Crucible Soft --> Cooked
public static Block emptySoftCrucible;
public static Block emptyCookedCrucible;
public static Block filledWaterCrucible;
public static Block boilingWaterCrucible;
public static Block tanWaterCrucible;
public static Block slackWaterCrucible;
public static final void init() {
GameRegistry.registerBlock(testBlock = new TestBlock("testBlock", Material.rock), "testBlock");
Fluid fluidSmoke = new Fluid("blocksmoke").setDensity(-1000).setTemperature(310).setGaseous(true).setBlock(blockSmoke).setViscosity(0);
FluidRegistry.registerFluid(fluidSmoke);
blockSmoke = new BlockSmoke(fluidSmoke, Material.water).setBlockName("blockSmoke");
GameRegistry.registerBlock(blockSmoke, Main.MODID + "_" + blockSmoke.getUnlocalizedName().substring(5));
fluidSmoke.setUnlocalizedName(blockSmoke.getUnlocalizedName());
fluidFiltered = new Fluid("blockFilteredWater").setDensity(1000).setTemperature(295).setGaseous(false).setBlock(blockFilteredWater).setViscosity(1000);
FluidRegistry.registerFluid(fluidFiltered);
blockFilteredWater = new BlockFilteredWater(fluidFiltered, Material.water).setBlockName("blockFilteredWater");
GameRegistry.registerBlock(blockFilteredWater, Main.MODID + "_" + blockFilteredWater.getUnlocalizedName().substring(5));
fluidFiltered.setUnlocalizedName(blockFilteredWater.getUnlocalizedName());
fluidTan = new Fluid("blockTannin").setDensity(1000).setTemperature(295).setGaseous(false).setBlock(blockTannin).setViscosity(1000);
FluidRegistry.registerFluid(fluidTan);
blockTannin = new BlockTannin(fluidTan, Material.water).setBlockName("blockTannin");
GameRegistry.registerBlock(blockTannin, Main.MODID + "_" + blockTannin.getUnlocalizedName().substring(5));
fluidTan.setUnlocalizedName(blockTannin.getUnlocalizedName());
fluidSlackedLime = new Fluid("blockSlackedLime").setGaseous(false).setBlock(blockSlackedLime).setViscosity(2000).setDensity(1500).setTemperature(400);
FluidRegistry.registerFluid(fluidSlackedLime);
blockSlackedLime = new BlockSlackedLime(fluidSlackedLime, Material.water).setBlockName("blockSlackedLime");
GameRegistry.registerBlock(blockSlackedLime, Main.MODID + "_" + blockSlackedLime.getUnlocalizedName().substring(5));
fluidSlackedLime.setUnlocalizedName(blockSlackedLime.getUnlocalizedName());
GameRegistry.registerBlock(limestoneRaw = new LimestoneRaw("limestoneRaw", Material.rock), "limestoneRaw");
GameRegistry.registerBlock(shitblock = new shitBlock("shitBlock", Material.clay), "shitBlock");
GameRegistry.registerBlock(eggWashedWall = new EggWashedWall("eggWashedWall", Material.rock), "eggWashedWall");
GameRegistry.registerBlock(eggWashedBrick = new EggWashedBrick("eggWashedBrick", Material.rock), "eggWashedBrick");
GameRegistry.registerBlock(wootzOre = new WootzOre("wootzOre", Material.rock), "wootzOre");
GameRegistry.registerBlock(formtable = new formTable("formTable", Material.wood), "formTable");
//GameRegistry.registerBlock(testForge = new TestForge("TestForge", Material.iron), "TestForge");
GameRegistry.registerBlock(forgeAnvil = new ForgeAnvil("forgeAnvil", Material.iron), "forgeAnvil");
GameRegistry.registerBlock(waterFilter = new WaterFilter("waterFilter", Material.iron), "waterFilter");
//GameRegistry.registerBlock(sandFilter = new SandFilter("sandFilter", Material.wood), "sandFilter");
//GameRegistry.registerBlock(sandFilterEmpty = new SandFilterEmpty("sandFilterEmpty", Material.wood), "sandFilterEmpty");
GameRegistry.registerBlock(solidFilter = new SolidFilter("solidFilter", Material.wood), "solidFilter");
GameRegistry.registerBlock(shelfFour = new ShelfFour("shelfFour", Material.wood), "shelfFour");
GameRegistry.registerBlock(firebox = new Firebox("firebox", Material.rock), "firebox");
GameRegistry.registerBlock(forge = new Forge("forge", Material.rock), "forge");
GameRegistry.registerBlock(cannon_28 = new Cannon_28("cannon_28", Material.iron), "cannon_28");
GameRegistry.registerBlock(cannonBall_28 = new CannonBallBlock28("cannonBallBlock_28", Material.iron), "cannonBallBlock_28");
/*GameRegistry.registerBlock(myIronIngot = new MyIronIngot("myIronIngot", Material.iron), "myIronIngot");
GameRegistry.registerBlock(damascusIngot = new DamascusIngot("damascusIngot", Material.iron), "damascusIngot");
GameRegistry.registerBlock(hotDamascusIngot = new HotDamascusIngot("hotDamascusIngot", Material.iron), "hotDamascusIngot");
GameRegistry.registerBlock(hotIronBlock = new HotIronBlock("hotIronBlock", Material.iron), "hotIronBlock");
GameRegistry.registerBlock(ironPlate = new IronPlate("ironPlate", Material.iron), "ironPlate");
GameRegistry.registerBlock(hotIronPlate = new HotIronPlate("hotIronPlate", Material.iron), "hotIronPlate");
GameRegistry.registerBlock(myDiamond = new Diamond("myDiamond", Material.glass), "myDiamond");
GameRegistry.registerBlock(myEmerald = new Emerald("myEmerald", Material.glass), "myEmerald");
GameRegistry.registerBlock(redstoneIngot = new RedstoneIngot("redstoneIngot", Material.rock), "redstoneIngot");
GameRegistry.registerBlock(hotRedstoneIngot = new HotRedstoneIngot("hotRedstoneIngot", Material.rock), "hotRedstoneIngot");
GameRegistry.registerBlock(lapisIngot = new LapisIngot("lapisIngot", Material.rock), "lapisIngot");
GameRegistry.registerBlock(hotLapisIngot = new HotLapisIngot("hotLapisIngot", Material.rock), "hotLapisIngot");*/
//CLEAN WOOD
/*
public static Block acaciaSplitLog;
public static Block birchSplitLog;
public static Block darkSplitLog;
public static Block jungleSplitLog;
public static Block oakSplitLog;
public static Block spruceSplitLog;
* */
GameRegistry.registerBlock(cleanOak = new CleanOak("cleanOak", Material.wood), "cleanOak");
GameRegistry.registerBlock(cleanAcacia = new CleanAcacia("cleanAcacia", Material.wood), "cleanAcacia");
GameRegistry.registerBlock(cleanJungle = new CleanJungle("cleanJungle", Material.wood), "cleanJungle");
GameRegistry.registerBlock(cleanDarkOak = new CleanDarkOak("cleanDarkOak", Material.wood), "cleanDarkOak");
GameRegistry.registerBlock(cleanBirch = new CleanBirch("cleanBirch", Material.wood), "cleanBirch");
GameRegistry.registerBlock(cleanSpruce = new CleanSpruce("cleanSpruce", Material.wood), "cleanSpruce");
GameRegistry.registerBlock(acaciaSplitLog = new AcaciaSplitLog("acaciaSplitLog", Material.wood), "acaciaSplitLog");
GameRegistry.registerBlock(birchSplitLog = new BirchSplitLog("birchSplitLog", Material.wood), "birchSplitLog");
GameRegistry.registerBlock(darkSplitLog = new DarkSplitLog("darkSplitLog", Material.wood), "darkSplitLog");
GameRegistry.registerBlock(jungleSplitLog = new JungleSplitLog("jungleSplitLog", Material.wood), "jungleSplitLog");
GameRegistry.registerBlock(oakSplitLog = new OakSplitLog("oakSplitLog", Material.wood), "oakSplitLog");
GameRegistry.registerBlock(spruceSplitLog = new SpruceSplitLog("spruceSplitLog", Material.wood), "spruceSplitLog");
GameRegistry.registerBlock(smallBarrelLid = new SmallBarrelLid("smallBarrelLid", Material.wood), "smallBarrelLid");
GameRegistry.registerBlock(smallBarrel = new SmallBarrel("smallBarrel", Material.wood), "smallBarrel");
//Empty Crucible
GameRegistry.registerBlock(emptySoftCrucible = new EmptySoftCrucible("emptySoftCrucible", Material.clay), "emptySoftCrucible");
GameRegistry.registerBlock(emptyCookedCrucible = new EmptyCookedCrucible("emptyCookedCrucible", Material.rock), "emptyCookedCrucible");
GameRegistry.registerBlock(filledWaterCrucible = new FilledWaterCrucible("filledWaterCrucible", Material.rock), "filledWaterCrucible");
GameRegistry.registerBlock(boilingWaterCrucible = new BoilingWaterCrucible("boilingWaterCrucible", Material.rock), "boilingWaterCrucible");
GameRegistry.registerBlock(tanWaterCrucible = new TanWaterCrucible("tanWaterCrucible", Material.rock), "tanWaterCrucible");
GameRegistry.registerBlock(slackWaterCrucible = new SlackWaterCrucible("slackWaterCrucible", Material.rock), "slackWaterCrucible");
//CRUCIBLE REGISTRY
GameRegistry.registerBlock(crucibleIronOre = new CrucibleIronOre(Material.rock, "crucibleIronOre"), "crucibleIronOre");
GameRegistry.registerBlock(crucibleIronIngot = new CrucibleIronIngot(Material.rock, "crucibleIronIngot"), "crucibleIronIngot");
GameRegistry.registerBlock(crucibleWootz = new CrucibleWootz(Material.rock, "crucibleWootz"), "crucibleWootz");
GameRegistry.registerBlock(crucibleLapis = new CrucibleLapis(Material.rock, "crucibleLapis"), "crucibleLapis");
GameRegistry.registerBlock(crucibleRedstone = new CrucibleRedstone(Material.rock, "crucibleRedstone"), "crucibleRedstone");
//INGOT REGISTRY
GameRegistry.registerBlock(refinedIron = new RefinedIron("refinedIron", Material.rock), "refinedIron");
GameRegistry.registerBlock(damascus = new DamascusIngot("damascus", Material.rock), "damascus");
GameRegistry.registerBlock(ironPlate = new IronPlate("ironPlate", Material.iron), "ironPlate");
GameRegistry.registerBlock(redstoneIngot = new RedstoneIngot("redstoneIngot", Material.rock), "redstoneIngot");
GameRegistry.registerBlock(lapisIngot = new LapisIngot("lapisIngot", Material.rock), "lapisIngot");
GameRegistry.registerBlock(myDiamond = new Diamond("myDiamond", Material.glass), "myDiamond");
GameRegistry.registerBlock(myEmerald = new Emerald("myEmerald", Material.glass), "myEmerald");
}
}

View File

@@ -0,0 +1,61 @@
package com.kitsu.medievalcraft.block;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.TileEntityTestBlock;
import com.kitsu.medievalcraft.tileents.crucible.TileCrucibleIronOre;
import com.kitsu.medievalcraft.util.CustomTab;
public class TestBlock extends BlockContainer {
public TestBlock (String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
//this.setCreativeTab(CustomTab.MedievalCraftTab);
//this.setHardness(1.0F);
//this.setResistance(1.0F);
//this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
//this.setBlockBounds(0.2F, 0.0F, 0.25F,
// 0.8F, 0.66F, 0.8F);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileCrucibleIronOre();
}
@Override
public int quantityDropped(Random p_149745_1_)
{
return 1;
}
@Override
public int getRenderType() {
return RenderId.testBlockID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,53 @@
package com.kitsu.medievalcraft.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class WootzOre extends Block {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public WootzOre(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(6.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "wootzOre");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "wootzOre");
//top
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "wootzOre");
//bot
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "wootzOre");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return side == 1 ? this.iconTop : (side == 0 ? this.iconBot : (side != metadata ? this.blockIcon : this.iconSide));
}
}

View File

@@ -0,0 +1,84 @@
package com.kitsu.medievalcraft.block.cannon;
import java.util.Random;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.cannon.TileCannonBall28;
import com.kitsu.medievalcraft.tileents.ingots.TileEntityMyDiamond;
import com.kitsu.medievalcraft.util.CustomTab;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CannonBallBlock28 extends BlockContainer {
public CannonBallBlock28(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(8.0F);
this.setHarvestLevel("pickaxe",1, 0);
this.setStepSound(soundTypeStone);
//this.setLightLevel(2.0F);
//xmin, ymin, zmin,
this.setBlockBounds(0.38F, 0.0F, 0.38F,
//xmax, ymax, zmax
0.62F, 0.35F, 0.62F);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
int a = player.inventory.currentItem;
if(!world.isRemote){
if(player.inventory.getStackInSlot(a)!=null){
if(player.getHeldItem().getItem()==Item.getItemFromBlock(this)){
ItemStack jar = new ItemStack(this);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(this);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileCannonBall28();
}
@Override
public int getRenderType() {
return RenderId.my28CannonBallID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,387 @@
package com.kitsu.medievalcraft.block.cannon;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.Random;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.entity.EntityCannonBall;
import com.kitsu.medievalcraft.entity.EntityModelArrow;
import com.kitsu.medievalcraft.entity.ProjectileCannonBall;
import com.kitsu.medievalcraft.gui.GuiHandler;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.cannon.TileCannon_28;
import com.kitsu.medievalcraft.tileents.machine.TileEntityFirebox;
import com.kitsu.medievalcraft.util.CannonUtil;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import jdk.nashorn.internal.runtime.regexp.joni.MatcherFactory;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityLargeFireball;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class Cannon_28 extends BlockContainer implements CannonUtil{
private final Random random = new Random();
public Cannon_28(String unlocalizedName, Material material) {
super(material.iron);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeMetal);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.0F, 0.0F,
1.0F, 0.85F, 1.0F);
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face){
return false;
}
private Entity shootCannon(World world, Integer x, Integer y, Integer z){
EntityCannonBall cannonball = null;
TileCannon_28 tile = null;
Item ball = null;
if(!world.isRemote){
tile = (TileCannon_28) world.getTileEntity(x, y, z);
ball = new ItemStack(ModBlocks.cannonBall_28, 0, 1).getItem();
if(tile.getStackInSlot(0)!=null && tile.getStackInSlot(0).getItem()==Items.gunpowder){
tile.isOn=true;
tile.smoke=true;
world.playSoundEffect(x, y, z, (Main.MODID + ":cannon1"), 2.0f, world.rand.nextFloat()/0.5f * 0.1F + 0.8F);
for(int i=0; i < world.playerEntities.size(); i++) {
EntityPlayer test = (EntityPlayer)world.playerEntities.get(i);
Vec3 vecTest = Vec3.createVectorHelper(test.posX, test.posY, test.posZ);
Vec3 vecPlayer = Vec3.createVectorHelper(x, y, z);
if (vecPlayer.distanceTo(vecTest) < 200.0F && vecPlayer.distanceTo(vecTest) > 10.0F)
{
world.playSoundAtEntity(test, (Main.MODID + ":cannon1"), (float) (200-(vecPlayer.distanceTo(vecTest)))/400, 1.0F);
}
}
if(tile.getStackInSlot(1)!=null){
if(tile.getStackInSlot(1).getItem()==ball){
tile.decrStackSize(1, 1);
cannonball = new EntityCannonBall(world, (double)x+((Math.sin(Math.toRadians(angles[world.getBlockMetadata(x, y, z)])))/2), (double)y+0.5, (double)z+((Math.cos(Math.toRadians(angles[world.getBlockMetadata(x, y, z)])))/2), null);
//System.out.println(angles[world.getBlockMetadata(x, y, z)]);
//System.out.println(Math.cos(Math.toRadians(angles[world.getBlockMetadata(x, y, z)])));
//System.out.println(Math.sin(Math.toRadians(angles[world.getBlockMetadata(x, y, z)])));
//cannonball.setVelocity(((tile.getStackInSlot(0).stackSize*(Math.sin(Math.toRadians(angles[world.getBlockMetadata(x, y, z)]))))-(world.rand.nextFloat()/4)),0.25, ((tile.getStackInSlot(0).stackSize*(Math.cos(Math.toRadians(angles[world.getBlockMetadata(x, y, z)]))))-(world.rand.nextFloat()/4)));
cannonball.motionX = ((tile.getStackInSlot(0).stackSize*(Math.sin(Math.toRadians(angles[world.getBlockMetadata(x, y, z)]))))-(world.rand.nextFloat()/4));
cannonball.motionY = 0.02;
cannonball.motionZ = ((tile.getStackInSlot(0).stackSize*(Math.cos(Math.toRadians(angles[world.getBlockMetadata(x, y, z)]))))-(world.rand.nextFloat()/4));
tile.setInventorySlotContents(0, null);
tile.markForUpdate();
tile.markDirty();
}
}
}
}
tile.markForUpdate();
tile.markDirty();
return cannonball;
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(!world.isRemote){
TileCannon_28 tileEnt = (TileCannon_28) world.getTileEntity(x, y, z);
if(tileEnt.isOn==false){
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem().getItem()==Items.flint_and_steel){
world.spawnEntityInWorld(shootCannon(world,x,y,z));
tileEnt.smoke=true;
tileEnt.markForUpdate();
tileEnt.markDirty();
return true;
}
}
}
if (!player.isSneaking()) {
if(player.inventory.getCurrentItem()==null||player.inventory.getCurrentItem().getItem()!=Items.flint_and_steel){
player.openGui(Main.instance, GuiHandler.guiIDcannon28, world, x, y, z);
return true;
}
}
}
return false;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block){
if(!world.isRemote){
if (world.isBlockIndirectlyGettingPowered(x, y, z))
{
TileCannon_28 tileEnt = (TileCannon_28) world.getTileEntity(x, y, z);
if(tileEnt.isOn==false){
world.spawnEntityInWorld(shootCannon(world, x, y, z));
tileEnt.smoke = true;
tileEnt.markForUpdate();
tileEnt.markDirty();
}
}
}
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
/*@Override
public void setBlockBoundsBasedOnState(IBlockAccess iBlock, int x, int y, int z)
{
int l = iBlock.getBlockMetadata(x, y, z) & 7;
switch (l)
{
case 1:
default:
this.setBlockBounds(0F, 0.0F, 0F, 1F, 1F, 1F);
break;
case 2:
this.setBlockBounds(0F, 0.0F, 0F, 1F, 1F, 1F);
break;
case 3:
this.setBlockBounds(0F, 0.0F, 0F, 1F, 1F, 1F);
break;
case 4:
this.setBlockBounds(0F, 0.0F, 0F, 1F, 1F, 1F);
break;
case 5:
this.setBlockBounds(0F, 0.0F, 0F, 1F, 1F, 1F);
}
}*/
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
/*@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
this.setBlockBoundsBasedOnState(world, x, y, z);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}*/
/**
* Called when the block is placed in the world.
*/
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
{
//22.5
//11.25
if(!world.isRemote){
double a = living.rotationYaw;
if (a<0){
a=360+a;
}
//a = a;
System.out.println(living.rotationYaw);
System.out.println(a);
if(a >= 180-11.25 && a <= 180+11.25){
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
System.out.println("0");
}
if(a >= 202.5-11.25 && a <= 202.5+11.25){
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
System.out.println("1");
}
if(a >= 225-11.25 && a <= 225+11.25){
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
System.out.println("2");
}
if(a >= 247.5-11.25 && a <= 247.5+11.25){
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
System.out.println("3");
}
if(a >= 270-11.25 && a <= 270+11.25){
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
System.out.println("4");
}
if(a >= 292.5-11.25 && a <= 292.5+11.25){
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
System.out.println("5");
}
if(a >= 315-11.25 && a <= 315+11.25){
world.setBlockMetadataWithNotify(x, y, z, 6, 2);
System.out.println("6");
}
if(a >= 337.5-11.25 && a <= 337.5+11.25){
world.setBlockMetadataWithNotify(x, y, z, 7, 2);
System.out.println("7");
}
if(a <= 0+11.25 && a >=0){
world.setBlockMetadataWithNotify(x, y, z, 8, 2);
System.out.println("8");
}
if(a >= 360-11.25 && a <= 360){
world.setBlockMetadataWithNotify(x, y, z, 8, 2);
System.out.println("8");
}
if(a >= 22.5-11.25 && a <= 22.5+11.25){
world.setBlockMetadataWithNotify(x, y, z, 9, 2);
System.out.println("9");
}
if(a >= 45-11.25 && a <= 45+11.25){
world.setBlockMetadataWithNotify(x, y, z, 10, 2);
System.out.println("10");
}
if(a >= 67.5-11.25 && a <= 67.5+11.25){
world.setBlockMetadataWithNotify(x, y, z, 11, 2);
System.out.println("11");
}
if(a >= 90-11.25 && a <= 90+11.25){
world.setBlockMetadataWithNotify(x, y, z, 12, 2);
System.out.println("12");
}
if(a >= 112.5-11.25 && a <= 112.5+11.25){
world.setBlockMetadataWithNotify(x, y, z, 13, 2);
System.out.println("13");
}
if(a >= 135-11.25 && a <= 135+11.25){
world.setBlockMetadataWithNotify(x, y, z, 14, 2);
System.out.println("14");
}
if(a >= 157.5-11.25 && a <= 157.5+11.25){
world.setBlockMetadataWithNotify(x, y, z, 15, 2);
System.out.println("15");
}
}
}
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
if(!world.isRemote){
int last = world.getBlockMetadata(x, y, z);
if(player.isSneaking()==true){
if(world.getBlockMetadata(x, y, z)==15){
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
System.out.println("A: " + world.getBlockMetadata(x,y,z));
}
if(world.getBlockMetadata(x, y, z)<15 && last !=15){
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)+1, 2);
System.out.println("B: " + world.getBlockMetadata(x,y,z));
}
}
if(!player.isSneaking()==true){
if(world.getBlockMetadata(x, y, z)>0){
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)-1, 2);
System.out.println("C: " + world.getBlockMetadata(x,y,z));
}
if(world.getBlockMetadata(x, y, z)==0 && last != 1){
world.setBlockMetadataWithNotify(x, y, z, 15, 2);
System.out.println("D: " + world.getBlockMetadata(x,y,z));
}
}
}
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileCannon_28 tileEnt = (TileCannon_28) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileCannon_28();
}
@Override
public int getRenderType() {
return RenderId.cannon_28ID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
}
}
/*
if(world.isRemote){
TileCannon_28 tileEnt = (TileCannon_28) world.getTileEntity(x, y, z);
if(tileEnt.smoke==true){
System.out.println("make smoke");
for(int f = 0; f < 10; f++){
world.spawnParticle("cloud", x + (Math.sin(Math.toRadians(angles[world.getBlockMetadata(x, y, z)])))+world.rand.nextFloat()/10, y+world.rand.nextFloat()/10, z + (Math.cos(Math.toRadians(angles[world.getBlockMetadata(x, y, z)]))+world.rand.nextFloat()/10),
(Math.sin(Math.toRadians(angles[world.getBlockMetadata(x, y, z)])))/5, 0.2D, (Math.cos(Math.toRadians(angles[world.getBlockMetadata(x, y, z)])))/5);
}
tileEnt.smoke=false;
}
}
*/

View File

@@ -0,0 +1,81 @@
package com.kitsu.medievalcraft.block.crucible;
import java.util.Random;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.util.CustomTab;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public abstract class CrucibleBase extends BlockContainer {
//comment
protected CrucibleBase(Material mat, String unlocalizedName) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(2.0F);
this.setResistance(1.0F);
this.setHarvestLevel("pickaxe", 0);
this.setStepSound(soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.2F, 0.0F, 0.25F,
0.8F, 0.66F, 0.8F);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Item.getItemFromBlock(this)){
ItemStack jar = new ItemStack(this);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(this);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
return true;
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return Item.getItemFromBlock(this);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getRenderType() {
return 0;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,91 @@
package com.kitsu.medievalcraft.block.crucible;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.TileCrucibleIronOre;
public class CrucibleIronIngot extends CrucibleBase{
public CrucibleIronIngot(Material mat, String unlocalizedName) {
super(mat, unlocalizedName);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileCrucibleIronOre();
}
@Override
public int getRenderType() {
return RenderId.coolCrucibleID;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
if(!world.isRemote){
TileCrucibleIronOre tile = (TileCrucibleIronOre) world.getTileEntity(x, y, z);
if(tile.cooked==false && tile.hot==false){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Item.getItemFromBlock(this)){
ItemStack jar = new ItemStack(this);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(this);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
}
return true;
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return null;
}
@Override
public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta){
if(!world.isRemote){
if(meta == 0){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.stone_slab, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.emptyCookedCrucible, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Items.iron_ingot, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.sand, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Items.coal, 1, 1)));
}
if(meta == 1){
}
if(meta == 2){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.stone_slab, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.emptyCookedCrucible, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.refinedIron, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.glass, 1, 0)));
}
}
}
}

View File

@@ -0,0 +1,113 @@
package com.kitsu.medievalcraft.block.crucible;
import java.util.Random;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.TileCrucibleIronOre;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CrucibleIronOre extends CrucibleBase{
public CrucibleIronOre(Material mat, String unlocalizedName) {
super(mat, unlocalizedName);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileCrucibleIronOre();
}
@Override
public int getRenderType() {
return RenderId.coolCrucibleID;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
if(!world.isRemote){
TileCrucibleIronOre tile = (TileCrucibleIronOre) world.getTileEntity(x, y, z);
if(tile.cooked==false && tile.hot==false){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Item.getItemFromBlock(this)){
ItemStack jar = new ItemStack(this);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(this);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
}
return true;
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return null;
}
@Override
public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta){
if(!world.isRemote){
if(meta == 0){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.stone_slab, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.emptyCookedCrucible, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.iron_ore, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.sand, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Items.coal, 1, 1)));
}
if(meta == 1){
}
if(meta == 2){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.stone_slab, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.emptyCookedCrucible, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.refinedIron, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.glass, 1, 0)));
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
super.randomDisplayTick(world, x, y, z, random);
if(world.getBlockMetadata(x, y, z)==1){
if (random.nextInt(7) == 0) {
world.spawnParticle("largesmoke", x + 0.3D, y + 0.6D, z + 0.34D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 1) {
world.spawnParticle("cloud", x + 0.3D, y + 0.6D, z + 0.34D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 2) {
world.spawnParticle("largesmoke", x + 0.75D, y + 0.6D, z + 0.6D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 3) {
world.spawnParticle("cloud", x + 0.45D, y + 0.6D, z + 0.75D, 0.0D, 0.0D, 0.0D);
}
}
}
}

View File

@@ -0,0 +1,114 @@
package com.kitsu.medievalcraft.block.crucible;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.TileCrucibleLapis;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CrucibleLapis extends CrucibleBase{
public CrucibleLapis(Material mat, String unlocalizedName) {
super(mat, unlocalizedName);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileCrucibleLapis();
}
@Override
public int getRenderType() {
return RenderId.coolCrucibleID;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
if(!world.isRemote){
TileCrucibleLapis tile = (TileCrucibleLapis) world.getTileEntity(x, y, z);
if(tile.cooked==false && tile.hot==false){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Item.getItemFromBlock(this)){
ItemStack jar = new ItemStack(this);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(this);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
}
return true;
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return null;
}
@Override
public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta){
if(!world.isRemote){
if(meta == 0){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.stone_slab, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.emptyCookedCrucible, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.lapis_block, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.sand, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Items.coal, 1, 1)));
}
if(meta == 1){
}
if(meta == 2){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.stone_slab, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.emptyCookedCrucible, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.refinedIron, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.glass, 1, 0)));
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
super.randomDisplayTick(world, x, y, z, random);
if(world.getBlockMetadata(x, y, z)==1){
if (random.nextInt(7) == 0) {
world.spawnParticle("largesmoke", x + 0.3D, y + 0.6D, z + 0.34D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 1) {
world.spawnParticle("cloud", x + 0.3D, y + 0.6D, z + 0.34D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 2) {
world.spawnParticle("largesmoke", x + 0.75D, y + 0.6D, z + 0.6D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 3) {
world.spawnParticle("cloud", x + 0.45D, y + 0.6D, z + 0.75D, 0.0D, 0.0D, 0.0D);
}
}
}
}

View File

@@ -0,0 +1,114 @@
package com.kitsu.medievalcraft.block.crucible;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.TileCrucibleRedstone;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CrucibleRedstone extends CrucibleBase{
public CrucibleRedstone(Material mat, String unlocalizedName) {
super(mat, unlocalizedName);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileCrucibleRedstone();
}
@Override
public int getRenderType() {
return RenderId.coolCrucibleID;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
if(!world.isRemote){
TileCrucibleRedstone tile = (TileCrucibleRedstone) world.getTileEntity(x, y, z);
if(tile.cooked==false && tile.hot==false){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Item.getItemFromBlock(this)){
ItemStack jar = new ItemStack(this);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(this);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
}
return true;
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return null;
}
@Override
public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta){
if(!world.isRemote){
if(meta == 0){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.stone_slab, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.emptyCookedCrucible, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.redstone_block, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.sand, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Items.coal, 1, 1)));
}
if(meta == 1){
}
if(meta == 2){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.stone_slab, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.emptyCookedCrucible, 1, 0)));
//world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.redstoneIngot, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.glass, 1, 0)));
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
super.randomDisplayTick(world, x, y, z, random);
if(world.getBlockMetadata(x, y, z)==1){
if (random.nextInt(7) == 0) {
world.spawnParticle("largesmoke", x + 0.3D, y + 0.6D, z + 0.34D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 1) {
world.spawnParticle("cloud", x + 0.3D, y + 0.6D, z + 0.34D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 2) {
world.spawnParticle("largesmoke", x + 0.75D, y + 0.6D, z + 0.6D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 3) {
world.spawnParticle("cloud", x + 0.45D, y + 0.6D, z + 0.75D, 0.0D, 0.0D, 0.0D);
}
}
}
}

View File

@@ -0,0 +1,114 @@
package com.kitsu.medievalcraft.block.crucible;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.TileCrucibleIronOre;
import com.kitsu.medievalcraft.tileents.crucible.TileCrucibleWootz;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CrucibleWootz extends CrucibleBase{
public CrucibleWootz(Material mat, String unlocalizedName) {
super(mat, unlocalizedName);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileCrucibleWootz();
}
@Override
public int getRenderType() {
return RenderId.coolCrucibleID;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
if(!world.isRemote){
TileCrucibleWootz tile = (TileCrucibleWootz) world.getTileEntity(x, y, z);
if(tile.cooked==false && tile.hot==false){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Item.getItemFromBlock(this)){
ItemStack jar = new ItemStack(this);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(this);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
}
return true;
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return null;
}
@Override
public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta){
if(!world.isRemote){
if(meta == 0){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.stone_slab, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.emptyCookedCrucible, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.wootzOre, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.sand, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Items.coal, 1, 1)));
}
if(meta == 1){
}
if(meta == 2){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.stone_slab, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.emptyCookedCrucible, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.damascus, 1, 0)));
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(Blocks.glass, 1, 0)));
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
super.randomDisplayTick(world, x, y, z, random);
if(world.getBlockMetadata(x, y, z)==1){
if (random.nextInt(7) == 0) {
world.spawnParticle("largesmoke", x + 0.3D, y + 0.6D, z + 0.34D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 1) {
world.spawnParticle("cloud", x + 0.3D, y + 0.6D, z + 0.34D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 2) {
world.spawnParticle("largesmoke", x + 0.75D, y + 0.6D, z + 0.6D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(7) == 3) {
world.spawnParticle("cloud", x + 0.45D, y + 0.6D, z + 0.75D, 0.0D, 0.0D, 0.0D);
}
}
}
}

View File

@@ -0,0 +1,119 @@
package com.kitsu.medievalcraft.block.crucible.empty;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.empty.TileEntityBoilingWaterCrucible;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BoilingWaterCrucible extends BlockContainer {
public BoilingWaterCrucible (String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(1.0F);
this.setResistance(1.0F);
//this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.2F, 0.0F, 0.25F,
0.8F, 0.66F, 0.8F);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
if(!world.isRemote){
TileEntityBoilingWaterCrucible boilingEnt = (TileEntityBoilingWaterCrucible) world.getTileEntity(x, y, z);
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==ModItems.itemBark){
if(player.inventory.getStackInSlot(a).stackSize >= 16){
if((boilingEnt.dotan==false)&&(boilingEnt.dolime!=true)){
player.inventory.decrStackSize(a, 10+world.rand.nextInt(6));
boilingEnt.dotan=true;
}
}
}
if(player.inventory.getStackInSlot(a).getItem()==ModItems.limestoneDust){
if(player.inventory.getStackInSlot(a).stackSize >= 16){
if((boilingEnt.dolime==false)&&(boilingEnt.dotan!=true)){
player.inventory.decrStackSize(a, 8+world.rand.nextInt(8));
boilingEnt.dolime=true;
}
}
}
}
}
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityBoilingWaterCrucible();
}
@Override
public int quantityDropped(Random p_149745_1_)
{
return 1;
}
@Override
public Item getItemDropped(int par1, Random random, int par3) {
return Item.getItemFromBlock(ModBlocks.emptyCookedCrucible);
}
@Override
public Item getItem(World world, int par2, int par3, int par4) {
return Item.getItemFromBlock(ModBlocks.emptyCookedCrucible);
}
@Override
public int getRenderType() {
return RenderId.filledWaterCrucibleID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
super.randomDisplayTick(world, x, y, z, random);
if (random.nextInt(3) == 0) {
world.spawnParticle("cloud", (x + 0.5D) + (random.nextGaussian()/25), (y + 0.85D), (z + 0.5D) + (random.nextGaussian()/25), (random.nextGaussian()/100), 0.07D, (random.nextGaussian()/100));
//world.spawnParticle("droplet", (x + 0.5D) + (random.nextGaussian()/50), (y + 0.5D), (z + 0.5D) + (random.nextGaussian()/50), 0.0D, 0.1D, 0.0D);
}
}
}

View File

@@ -0,0 +1,109 @@
package com.kitsu.medievalcraft.block.crucible.empty;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.empty.TileEntityEmptyCookedCrucible;
import com.kitsu.medievalcraft.util.CustomTab;
public class EmptyCookedCrucible extends BlockContainer {
public EmptyCookedCrucible (String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
//this.setHardness(1.0F);
//this.setResistance(1.0F);
//this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.2F, 0.0F, 0.25F,
0.8F, 0.66F, 0.8F);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Items.water_bucket){
ItemStack bucket = new ItemStack(Items.bucket);
player.inventory.setInventorySlotContents(a, bucket);
if(!world.isRemote){
world.setBlock(x, y, z, ModBlocks.filledWaterCrucible, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Item.getItemFromBlock(ModBlocks.emptyCookedCrucible)){
ItemStack jar = new ItemStack(ModBlocks.emptyCookedCrucible);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(ModBlocks.emptyCookedCrucible);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityEmptyCookedCrucible();
}
@Override
public int quantityDropped(Random p_149745_1_)
{
return 1;
}
@Override
public Item getItemDropped(int par1, Random random, int par3) {
return Item.getItemFromBlock(ModBlocks.emptyCookedCrucible);
}
@Override
public Item getItem(World world, int par2, int par3, int par4) {
return Item.getItemFromBlock(ModBlocks.emptyCookedCrucible);
}
@Override
public int getRenderType() {
return RenderId.emptyCrucibleID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,73 @@
package com.kitsu.medievalcraft.block.crucible.empty;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.empty.TileEntitySoftEmptyCrucible;
import com.kitsu.medievalcraft.util.CustomTab;
public class EmptySoftCrucible extends BlockContainer {
public EmptySoftCrucible (String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
//this.setHardness(1.0F);
//this.setResistance(1.0F);
//this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.2F, 0.0F, 0.25F,
0.8F, 0.66F, 0.8F);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntitySoftEmptyCrucible();
}
@Override
public int quantityDropped(Random p_149745_1_)
{
return 1;
}
@Override
public Item getItemDropped(int par1, Random random, int par3) {
return Item.getItemFromBlock(ModBlocks.emptySoftCrucible);
}
@Override
public Item getItem(World world, int par2, int par3, int par4) {
return Item.getItemFromBlock(ModBlocks.emptySoftCrucible);
}
@Override
public int getRenderType() {
return RenderId.emptyCrucibleID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,101 @@
package com.kitsu.medievalcraft.block.crucible.empty;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.empty.TileEntityFilledWaterCrucible;
import com.kitsu.medievalcraft.util.CustomTab;
public class FilledWaterCrucible extends BlockContainer {
public FilledWaterCrucible (String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(1.0F);
this.setResistance(1.0F);
//this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.2F, 0.0F, 0.25F,
0.8F, 0.66F, 0.8F);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
int a = player.inventory.currentItem;
//System.out.println(player.inventory.getStackInSlot(a));
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Items.bucket){
player.inventory.decrStackSize(a, 1);
ItemStack bucket = new ItemStack(Items.water_bucket);
int b = player.inventory.getFirstEmptyStack();
player.inventory.setInventorySlotContents(b, bucket);
if(!world.isRemote){
world.setBlock(x, y, z, ModBlocks.emptyCookedCrucible, 0, 2);
}
}
}
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityFilledWaterCrucible();
}
@Override
public int quantityDropped(Random p_149745_1_)
{
return 1;
}
@Override
public Item getItemDropped(int par1, Random random, int par3) {
return Item.getItemFromBlock(ModBlocks.emptyCookedCrucible);
}
@Override
public Item getItem(World world, int par2, int par3, int par4) {
return Item.getItemFromBlock(ModBlocks.emptyCookedCrucible);
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
}
@Override
public int getRenderType() {
return RenderId.filledWaterCrucibleID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,92 @@
package com.kitsu.medievalcraft.block.crucible.empty;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.empty.TileEntitySlackWaterCrucible;
import com.kitsu.medievalcraft.util.CustomTab;
public class SlackWaterCrucible extends BlockContainer {
public SlackWaterCrucible (String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
//this.setHardness(1.0F);
//this.setResistance(1.0F);
//this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.2F, 0.0F, 0.25F,
0.8F, 0.66F, 0.8F);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Items.bucket){
ItemStack slack = new ItemStack(ModItems.slackBucket);
player.inventory.consumeInventoryItem(player.inventory.getStackInSlot(a).getItem());
int b = player.inventory.getFirstEmptyStack();
player.inventory.setInventorySlotContents(b, slack);
world.setBlock(x, y, z, ModBlocks.emptyCookedCrucible, 0, 2);
player.inventoryContainer.detectAndSendChanges();
}
}
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntitySlackWaterCrucible();
}
@Override
public int quantityDropped(Random p_149745_1_)
{
return 1;
}
@Override
public Item getItemDropped(int par1, Random random, int par3) {
return Item.getItemFromBlock(ModBlocks.emptyCookedCrucible);
}
@Override
public Item getItem(World world, int par2, int par3, int par4) {
return Item.getItemFromBlock(ModBlocks.emptyCookedCrucible);
}
@Override
public int getRenderType() {
return RenderId.filledWaterCrucibleID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,92 @@
package com.kitsu.medievalcraft.block.crucible.empty;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.crucible.empty.TileEntityTanWaterCrucible;
import com.kitsu.medievalcraft.util.CustomTab;
public class TanWaterCrucible extends BlockContainer {
public TanWaterCrucible (String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
//this.setHardness(1.0F);
//this.setResistance(1.0F);
//this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.2F, 0.0F, 0.25F,
0.8F, 0.66F, 0.8F);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Items.bucket){
ItemStack tan = new ItemStack(ModItems.tanninBucket, 1);
player.inventory.consumeInventoryItem(player.inventory.getStackInSlot(a).getItem());
player.inventory.addItemStackToInventory(tan);
player.inventory.addItemStackToInventory(new ItemStack(ModItems.woodPulp, 6 + world.rand.nextInt(4)));
world.setBlock(x, y, z, ModBlocks.emptyCookedCrucible, 0, 2);
player.inventoryContainer.detectAndSendChanges();
}
}
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityTanWaterCrucible();
}
@Override
public int quantityDropped(Random p_149745_1_)
{
return 1;
}
@Override
public Item getItemDropped(int par1, Random random, int par3) {
return Item.getItemFromBlock(ModBlocks.emptyCookedCrucible);
}
@Override
public Item getItem(World world, int par2, int par3, int par4) {
return Item.getItemFromBlock(ModBlocks.emptyCookedCrucible);
}
@Override
public int getRenderType() {
return RenderId.filledWaterCrucibleID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,51 @@
package com.kitsu.medievalcraft.block.decorative;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class EggWashedBrick extends Block {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public EggWashedBrick(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(6.0F);
this.setStepSound(Block.soundTypeStone);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "eggwashbrickside");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "eggwashbrickside");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "eggwashbricktop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "eggwashbricktop");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return side == 1 ? this.iconTop : (side == 0 ? this.iconBot : (side != metadata ? this.blockIcon : this.iconSide));
}
}

View File

@@ -0,0 +1,51 @@
package com.kitsu.medievalcraft.block.decorative;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class EggWashedWall extends Block {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public EggWashedWall(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(6.0F);
this.setStepSound(Block.soundTypeStone);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "eggwashside");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "eggwashside");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "eggwashtop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "eggwashtop");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return side == 1 ? this.iconTop : (side == 0 ? this.iconBot : (side != metadata ? this.blockIcon : this.iconSide));
}
}

View File

@@ -0,0 +1,51 @@
package com.kitsu.medievalcraft.block.decorative;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class LimestoneRaw extends Block {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public LimestoneRaw(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(2.0F);
this.setResistance(4.0F);
this.setStepSound(Block.soundTypeStone);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "limestoneRawSide");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "limestoneRawSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "limestoneRawTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "limestoneRawTop");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return side == 1 ? this.iconTop : (side == 0 ? this.iconBot : (side != metadata ? this.blockIcon : this.iconSide));
}
}

View File

@@ -0,0 +1,55 @@
package com.kitsu.medievalcraft.block.fluid;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockFilteredWater extends BlockFluidClassic {
@SideOnly(Side.CLIENT)
protected IIcon stillIcon;
@SideOnly(Side.CLIENT)
protected IIcon flowingIcon;
public BlockFilteredWater(Fluid fluid, Material material) {
super(fluid, material);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setBlockTextureName(Main.MODID + ":" + this.getUnlocalizedName());
}
@Override
public IIcon getIcon(int side, int meta) {
return (side == 0 || side == 1)? stillIcon : flowingIcon;
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
stillIcon = register.registerIcon(Main.MODID + ":fluidFilteredStill");
flowingIcon = register.registerIcon(Main.MODID + ":fluidFilteredFlowing");
}
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
return super.canDisplace(world, x, y, z);
}
@Override
public boolean displaceIfPossible(World world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
return super.displaceIfPossible(world, x, y, z);
}
}

View File

@@ -0,0 +1,56 @@
package com.kitsu.medievalcraft.block.fluid;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockSlackedLime extends BlockFluidClassic {
@SideOnly(Side.CLIENT)
protected IIcon stillIcon;
@SideOnly(Side.CLIENT)
protected IIcon flowingIcon;
public BlockSlackedLime(Fluid fluid, Material material) {
super(fluid, material);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setBlockTextureName(Main.MODID + ":" + this.getUnlocalizedName());
}
@Override
public IIcon getIcon(int side, int meta) {
return (side == 0 || side == 1)? stillIcon : flowingIcon;
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
stillIcon = register.registerIcon(Main.MODID + ":fluidSlackStill");
flowingIcon = register.registerIcon(Main.MODID + ":fluidSlackFlowing");
}
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
return super.canDisplace(world, x, y, z);
}
@Override
public boolean displaceIfPossible(World world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
return super.displaceIfPossible(world, x, y, z);
}
}

View File

@@ -0,0 +1,89 @@
package com.kitsu.medievalcraft.block.fluid;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidFinite;
import net.minecraftforge.fluids.Fluid;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockSmoke extends BlockFluidFinite{
@SideOnly(Side.CLIENT)
protected IIcon stillIcon;
@SideOnly(Side.CLIENT)
protected IIcon flowingIcon;
public BlockSmoke(Fluid fluid, Material material) {
super(fluid, material);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setBlockTextureName(Main.MODID + ":" + this.getUnlocalizedName());
}
@Override
public IIcon getIcon(int side, int meta) {
return (side == 0 || side == 1)? stillIcon : flowingIcon;
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
stillIcon = register.registerIcon(Main.MODID + ":fluidStill");
flowingIcon = register.registerIcon(Main.MODID + ":fluidFlowing");
}
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
return super.canDisplace(world, x, y, z);
}
@Override
public boolean displaceIfPossible(World world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
return super.displaceIfPossible(world, x, y, z);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
super.randomDisplayTick(world, x, y, z, random);
if (random.nextInt(6) == 0) {
world.spawnParticle("cloud", x + 0.5D, y + 0.5D, z + 0.5D, 0.0D, 0.2D, 0.0D);
world.spawnParticle("largesmoke", x + 0.5D, y + 0.5D, z + 0.5D, 0.0D, 0.2D, 0.0D);
}
if (random.nextInt(6) == 1) {
world.spawnParticle("cloud", x + 0.8D, y + 0.5D, z + 0.5D, 0.0D, 0.2D, 0.0D);
world.spawnParticle("largesmoke", x + 0.8D, y + 0.5D, z + 0.5D, 0.0D, 0.2D, 0.0D);
}
if (random.nextInt(6) == 2) {
world.spawnParticle("cloud", x + 0.2D, y + 0.5D, z + 0.5D, 0.0D, 0.2D, 0.0D);
world.spawnParticle("largesmoke", x + 0.2D, y + 0.5D, z + 0.5D, 0.0D, 0.2D, 0.0D);
}
if (random.nextInt(6) == 3) {
world.spawnParticle("cloud", x + 0.5D, y + 0.5D, z + 0.8D, 0.0D, 0.2D, 0.0D);
world.spawnParticle("largesmoke", x + 0.5D, y + 0.5D, z + 0.8D, 0.0D, 0.2D, 0.0D);
}
if (random.nextInt(6) == 4) {
world.spawnParticle("cloud", x + 0.5D, y + 0.5D, z + 0.2D, 0.0D, 0.2D, 0.0D);
world.spawnParticle("largesmoke", x + 0.5D, y + 0.5D, z + 0.2D, 0.0D, 0.2D, 0.0D);
}
if (random.nextInt(6) == 5) {
world.spawnParticle("cloud", x + 0.8D, y + 0.5D, z + 0.2D, 0.0D, 0.2D, 0.0D);
world.spawnParticle("largesmoke", x + 0.8D, y + 0.5D, z + 0.2D, 0.0D, 0.2D, 0.0D);
}
}
}

View File

@@ -0,0 +1,55 @@
package com.kitsu.medievalcraft.block.fluid;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockTannin extends BlockFluidClassic {
@SideOnly(Side.CLIENT)
protected IIcon stillIcon;
@SideOnly(Side.CLIENT)
protected IIcon flowingIcon;
public BlockTannin(Fluid fluid, Material material) {
super(fluid, material);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setBlockTextureName(Main.MODID + ":" + this.getUnlocalizedName());
}
@Override
public IIcon getIcon(int side, int meta) {
return (side == 0 || side == 1)? stillIcon : flowingIcon;
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
stillIcon = register.registerIcon(Main.MODID + ":fluidTanStill");
flowingIcon = register.registerIcon(Main.MODID + ":fluidTanFlowing");
}
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
return super.canDisplace(world, x, y, z);
}
@Override
public boolean displaceIfPossible(World world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
return super.displaceIfPossible(world, x, y, z);
}
}

View File

@@ -0,0 +1,29 @@
package com.kitsu.medievalcraft.block.ingots;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.ingots.TileDamascus;
import com.kitsu.medievalcraft.tileents.ingots.TileMyIronIngot;
import com.kitsu.medievalcraft.util.CustomTab;
public class DamascusIngot extends IngotBase {
public DamascusIngot(String unlocalizedName, Material material) {
super(unlocalizedName, material);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileDamascus();
}
@Override
public int getRenderType() {
return RenderId.myironingotID;
}
}

View File

@@ -0,0 +1,86 @@
package com.kitsu.medievalcraft.block.ingots;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.ingots.TileEntityMyDiamond;
public class Diamond extends BlockContainer {
public Diamond(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
//this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(1.0F);
this.setResistance(1.0F);
this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeGlass);
//this.setLightLevel(2.0F);
//xmin, ymin, zmin,
this.setBlockBounds(0.38F, 0.0F, 0.38F,
//xmax, ymax, zmax
0.62F, 0.2F, 0.62F);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Items.diamond){
ItemStack jar = new ItemStack(Items.diamond);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(Items.diamond);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
return false;
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return Items.diamond;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityMyDiamond();
}
@Override
public int getRenderType() {
return RenderId.myDiamondID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,86 @@
package com.kitsu.medievalcraft.block.ingots;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.ingots.TileEntityMyEmerald;
public class Emerald extends BlockContainer {
public Emerald(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
//this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(1.0F);
this.setResistance(1.0F);
this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeGlass);
//this.setLightLevel(2.0F);
//xmin, ymin, zmin,
this.setBlockBounds(0.35F, 0.0F, 0.38F,
//xmax, ymax, zmax
0.65F, 0.15F, 0.62F);
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)!=null){
if(player.inventory.getStackInSlot(a).getItem()==Items.emerald){
ItemStack jar = new ItemStack(Items.emerald);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(Items.emerald);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
return false;
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return Items.emerald;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityMyEmerald();
}
@Override
public int getRenderType() {
return RenderId.myEmeraldID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,123 @@
package com.kitsu.medievalcraft.block.ingots;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public abstract class IngotBase extends BlockContainer {
private final Random random = new Random();
public static boolean makeParts;
public static int locX, locY, locZ;
public IngotBase(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(1.0F);
this.setResistance(1.0F);
this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeMetal);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.25F, 0.0F, 0.35F,
0.75F , 0.15F, 0.7F);
}
@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
return Item.getItemFromBlock(this);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return null;
}
@Override
public int quantityDropped(Random p_149745_1_)
{
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
if(makeParts == true){
parts(world, locX, locY, locZ);
makeParts = false;
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int aa, float bb, float cc, float ff){
//System.out.println(this.getUnlocalizedName());
//if(player.inventory.getCurrentItem().getItem()!=ModItems.forgeHammer){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a)==null){
ItemStack jar = new ItemStack(this);
player.inventory.setInventorySlotContents(a, jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
return true;
}
if(player.inventory.getStackInSlot(a)!=null && player.inventory.getCurrentItem().getItem()!=ModItems.forgeHammer){
if(player.inventory.getStackInSlot(a).getItem()==Item.getItemFromBlock(this)){
ItemStack jar = new ItemStack(this);
player.inventory.addItemStackToInventory(jar);
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
return true;
}
return false;
}
private void parts(World world, int x, int y, int z){
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
world.spawnParticle("lava", x+0.5D, y+0.5D, z+0.5D, 0, 0, 0);
}
@Override
public int getRenderType() {
return 0;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,33 @@
package com.kitsu.medievalcraft.block.ingots;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.ingots.TileIronPlate;
import com.kitsu.medievalcraft.tileents.ingots.TileMyIronIngot;
import com.kitsu.medievalcraft.util.CustomTab;
public class IronPlate extends IngotBase {
public IronPlate(String unlocalizedName, Material material) {
super(unlocalizedName, material);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.3F, 0.0F, 0.3F,
0.7F, 0.12F, 0.7F);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileIronPlate();
}
@Override
public int getRenderType() {
return RenderId.ironPlateID;
}
}

View File

@@ -0,0 +1,29 @@
package com.kitsu.medievalcraft.block.ingots;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.ingots.TileLapisIngot;
import com.kitsu.medievalcraft.util.CustomTab;
public class LapisIngot extends IngotBase {
public LapisIngot(String unlocalizedName, Material material) {
super(unlocalizedName, material);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileLapisIngot();
}
@Override
public int getRenderType() {
return RenderId.myironingotID;
}
}

View File

@@ -0,0 +1,30 @@
package com.kitsu.medievalcraft.block.ingots;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.ingots.TileMyIronIngot;
import com.kitsu.medievalcraft.tileents.ingots.TileRedstoneIngot;
import com.kitsu.medievalcraft.util.CustomTab;
public class RedstoneIngot extends IngotBase {
public RedstoneIngot(String unlocalizedName, Material material) {
super(unlocalizedName, material);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileRedstoneIngot();
}
@Override
public int getRenderType() {
return RenderId.myironingotID;
}
}

View File

@@ -0,0 +1,29 @@
package com.kitsu.medievalcraft.block.ingots;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.ingots.TileMyIronIngot;
import com.kitsu.medievalcraft.util.CustomTab;
public class RefinedIron extends IngotBase {
public RefinedIron(String unlocalizedName, Material material) {
super(unlocalizedName, material);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileMyIronIngot();
}
@Override
public int getRenderType() {
return RenderId.myironingotID;
}
}

View File

@@ -0,0 +1,284 @@
package com.kitsu.medievalcraft.block.machines;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileEntityFirebox;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Firebox extends BlockContainer{
private final Random random = new Random();
public Firebox(String unlocalizedName, Material material) {
super(material.rock);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.00F, 0.0F,
1.0F, 1.00F, 1.0F);
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face){
return true;
}
@Override
public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) {
if (this == ModBlocks.firebox && side == UP){
TileEntityFirebox tile = (TileEntityFirebox) world.getTileEntity(x, y, z);
if(tile.isOn==true){
if(this.getItemBurnTime(tile.getStackInSlot(0))>0){
return true;
}
}
}
return false;
}
@Override
public int getLightValue(IBlockAccess world,int x,int y,int z){
if(world.getBlockMetadata(x, y, z)==1){
return 15;
}
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
if(world.getBlockMetadata(x, y, z)==1){
if (rand.nextInt(24) == 0&&world.getBlock(x, y+1, z)!=Blocks.fire)
{
world.playSound((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "fire.fire", 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false);
}
int l;
float f;
float f1;
float f2;
for (l = 0; l < 3; ++l)
{
f = (float)(x+0.1) + ((rand.nextFloat()/1.25f));
f1 = (float)y+0.3f + rand.nextFloat() * 0.4F;
f2 = (float)(z+0.1) + ((rand.nextFloat()/1.25f));
world.spawnParticle("fire", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
}
}
}
//PACKETHANDLE FOR C
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileEntityFirebox tileEnt = (TileEntityFirebox) world.getTileEntity(x, y, z);
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
if((player.inventory.getCurrentItem().getItem()==Item.getItemFromBlock(Blocks.torch))||
(player.inventory.getCurrentItem().getItem()==Items.flint_and_steel)||
(player.inventory.getCurrentItem().getItem()==ModItems.fireBow)
){
world.setBlockMetadataWithNotify(x, y, z, 1, 3);
tileEnt.markForUpdate();
tileEnt.markDirty();
player.inventory.getCurrentItem().damageItem(1, player);
if(world.getBlock(x, y, z).equals(Blocks.air)){
world.setBlock(x, y+1, z, Blocks.fire, 0, 2);
}
}
}
if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
if(isItemFuel(player.inventory.getCurrentItem())==true){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
if (tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tileEnt.getStackInSlot(0));
tileEnt.setInventorySlotContents(0, null);
}
return true;
}
if (!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(0, 1);
}
}
return true;
}
}
tileEnt.markForUpdate();
tileEnt.markDirty();
return true;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
world.markBlockForUpdate(x, y, z);
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntityFirebox tileEnt = (TileEntityFirebox) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityFirebox();
}
public static int getItemBurnTime(ItemStack p_145952_0_)
{
if (p_145952_0_ == null)
{
return 0;
}
Item item = p_145952_0_.getItem();
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air)
{
Block block = Block.getBlockFromItem(item);
if (block == Blocks.wooden_slab)
{
return 150;
}
if (block.getMaterial() == Material.wood)
{
return 300;
}
if (block == Blocks.coal_block)
{
return 16000;
}
}
if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemHoe && ((ItemHoe)item).getToolMaterialName().equals("WOOD")) return 200;
if (item == Items.stick) return 100;
if (item == Items.coal) return 1600;
if (item == Items.lava_bucket) return 20000;
if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
if (item == Items.blaze_rod) return 2400;
return GameRegistry.getFuelValue(p_145952_0_);
}
public static boolean isItemFuel(ItemStack stack)
{
return getItemBurnTime(stack) > 0;
}
@Override
public int getRenderType() {
return RenderId.fireboxID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,396 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.packethandle.forge.MsgPacketForge;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
import com.kitsu.medievalcraft.util.CustomTab;
import com.kitsu.medievalcraft.util.TileForgePlaceables;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Forge extends BlockContainer implements TileForgePlaceables{
private final Random random = new Random();
public static int sideMeta;
private int c;
public Forge(String unlocalizedName, Material material) {
super(material.rock);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//this.setTickRandomly(true);
//this.isFlammable(world, x, y, z, face);
//(xmin, ymin, zmin,
// xmax, ymax, zmax)
this.setBlockBounds(0.0F, 0.0F, 0.0F,
1.0F, 1.0F, 1.0F);
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return true;
}
@Override
public int getLightValue(IBlockAccess world,int x,int y,int z){
if(world.getBlockMetadata(x, y, z)>3){
return 15;
}
return 0;
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
/*System.out.println("Update Tick");
if(world.getBlockMetadata(x, y, z)<4){
this.setLightLevel(0f);
}
if(world.getBlockMetadata(x, y, z)>3){
this.setLightLevel(1f);
}
*/
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
super.randomDisplayTick(world, x, y, z, random);
if(world.getBlockMetadata(x, y, z)>=4&&world.getBlockMetadata(x, y, z)<=7){
int l;
float f;
float f1;
float f2;
for (l = 0; l < 3; ++l)
{
f = (float)(x+0.25) + (rand.nextFloat()/2);
f1 = (float)y + rand.nextFloat() * 0.4F + 0.3F;
f2 = (float)(z+0.25) + (rand.nextFloat()/2);
world.spawnParticle("fire", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
}
}
if(world.getBlockMetadata(x, y, z)>=8){
int l;
float f;
float f1;
float f2;
for (l = 0; l < 3; ++l)
{
f = (float)(x+0.25) + (rand.nextFloat()/2);
//f1 = (float)y + rand.nextFloat() * 0.4F + 0.3F;
f1 = y+1.1f;
f2 = (float)(z+0.25) + (rand.nextFloat()/2);
world.spawnParticle("fire", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
}
for (l = 0; l < 3; ++l)
{
f = (float)(x+0.25) + (rand.nextFloat()/2);
f1 = (float)y + rand.nextFloat() * 0.4F + 0.3F;
f2 = (float)(z+0.25) + (rand.nextFloat()/2);
world.spawnParticle("fire", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D);
}
}
}
public static int determineOrientation(World p_150071_0_, int p_150071_1_, int p_150071_2_, int p_150071_3_, EntityLivingBase p_150071_4_)
{
if (MathHelper.abs((float)p_150071_4_.posX - (float)p_150071_1_) < 2.0F && MathHelper.abs((float)p_150071_4_.posZ - (float)p_150071_3_) < 2.0F)
{
double d0 = p_150071_4_.posY + 1.82D - (double)p_150071_4_.yOffset;
if (d0 - (double)p_150071_2_ > 2.0D){return 1;}
if ((double)p_150071_2_ - d0 > 0.0D) {return 0;}
}
int l = MathHelper.floor_double((double)(p_150071_4_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
return l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
int l = determineOrientation(world, x, y, z, player);
if(l==1){
l=5;
}
if(l==0){
l=5;
}
l=l-2;
world.setBlockMetadataWithNotify(x, y, z, l, 2);
//System.out.println(l);
world.markBlockForUpdate(x, y, z);
}
private boolean shouldPlace(ItemStack stack, EntityPlayer player){
for(int i=0; i<placeMe.size();i++){
if(player.inventory.getCurrentItem().getItem()==placeMe.get(i).getItem()){
return true;
}
}
return false;
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if(world.isRemote){
MovingObjectPosition mop = Minecraft.getMinecraft().renderViewEntity.rayTrace(5, 1.0F);
c = (int)mop.sideHit;
Main.sNet.sendToServer(new MsgPacketForge((int) c));
}
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
if((player.inventory.getCurrentItem().getItem()==Item.getItemFromBlock(Blocks.torch))||
(player.inventory.getCurrentItem().getItem()==Items.flint_and_steel)||
(player.inventory.getCurrentItem().getItem()==ModItems.fireBow)){
if(world.getBlockMetadata(x, y, z)<=3){
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)+4, 3);
tileEnt.markDirty();
tileEnt.markForUpdate();
}
tileEnt.markForUpdate();
if(tileEnt.getStackInSlot(1)!=null){
if(world.getBlockMetadata(x, y, z)>=4&&world.getBlockMetadata(x, y, z)<=7){
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)+4, 2);
}
}
}
}
if(sideMeta==1){
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem().getItem()==Items.coal){
if(tileEnt.getStackInSlot(1)!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(1).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(1).copy();
if(tileEnt.getStackInSlot(1).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(1, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
if(tileEnt.getStackInSlot(1)==null){
tileEnt.setInventorySlotContents(1, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(1)!=null){
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, tileEnt.getStackInSlot(1)));
tileEnt.setInventorySlotContents(1, null);
}
return true;
}
if (!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(1)!=null){
ItemStack pStack = tileEnt.getStackInSlot(1).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(1, 1);
}
}
return true;
}
}
if(sideMeta!=1){
if(player.inventory.getCurrentItem()!=null){
if(tileEnt.getStackInSlot(0)==null){
if(isItemFuel(player.inventory.getCurrentItem())==true){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
//world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z)+4, 3);
}
}
if(tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
if(isItemFuel(player.inventory.getCurrentItem())==true){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
}
return true;
}
if(player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, tileEnt.getStackInSlot(0)));
tileEnt.setInventorySlotContents(0, null);
tileEnt.markDirty();
tileEnt.markForUpdate();
}
return true;
}
if(!player.isSneaking()) {
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.decrStackSize(0, 1);
}
}
return true;
}
}
}
tileEnt.markForUpdate();
tileEnt.markDirty();
return true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileForge tileEnt = (TileForge) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileForge();
}
public static int getItemBurnTime(ItemStack p_145952_0_)
{
if (p_145952_0_ == null)
{
return 0;
}
Item item = p_145952_0_.getItem();
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air)
{
Block block = Block.getBlockFromItem(item);
if (block == Blocks.wooden_slab)
{
return 150;
}
if (block.getMaterial() == Material.wood)
{
return 300;
}
if (block == Blocks.coal_block)
{
return 16000;
}
}
if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemHoe && ((ItemHoe)item).getToolMaterialName().equals("WOOD")) return 200;
if (item == Items.stick) return 100;
if (item == Items.coal) return 1600;
if (item == Items.lava_bucket) return 20000;
if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
if (item == Items.blaze_rod) return 2400;
return GameRegistry.getFuelValue(p_145952_0_);
}
public static boolean isItemFuel(ItemStack stack)
{
return getItemBurnTime(stack) > 0;
}
@Override
public int getRenderType() {
return RenderId.forgeID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,196 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileEntityAnvilForge;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ForgeAnvil extends BlockContainer{
private final Random random = new Random();
public ForgeAnvil(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(2.0F);
this.setResistance(6.0F);
this.setStepSound(Block.soundTypeStone);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityAnvilForge();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z,EntityPlayer player, int metadata, float what, float these, float are) {
TileEntityAnvilForge tileEnt = (TileEntityAnvilForge) world.getTileEntity(x, y, z);
if(!world.isRemote){
if(player.inventory.getCurrentItem()!=null){
if (tileEnt.getStackInSlot(0)==null){
tileEnt.setInventorySlotContents(0, player.inventory.getCurrentItem());
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
tileEnt.markForUpdate();
}
if (tileEnt.getStackInSlot(0)!=null){
if(player.inventory.getCurrentItem()!=null){
ItemStack pStack = player.inventory.getCurrentItem().copy();
ItemStack sStack = tileEnt.getStackInSlot(0).copy();
ItemStack sStackTemp = tileEnt.getStackInSlot(0).copy();
if(tileEnt.getStackInSlot(0).stackSize < 64){
sStackTemp.stackSize++;
if ((sStack.getItem().equals(pStack.getItem())) && (sStack.getItemDamage() == pStack.getItemDamage()) ){
tileEnt.setInventorySlotContents(0, sStackTemp);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
tileEnt.markForUpdate();
return true;
}
if (player.isSneaking() && player.inventory.getCurrentItem()==null) {
if(tileEnt.getStackInSlot(0)!=null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, tileEnt.getStackInSlot(0));
tileEnt.setInventorySlotContents(0, null);
}
tileEnt.markForUpdate();
return true;
}
if (!player.isSneaking()){
if((player.inventory.getCurrentItem()==null)){
if(tileEnt.getStackInSlot(0)!=null){
ItemStack pStack = tileEnt.getStackInSlot(0).copy();
pStack.stackSize = 1;
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, pStack));
tileEnt.setInventorySlotContents(0, null);
tileEnt.markForUpdate();
}
}
tileEnt.markForUpdate();
return true;
}
}
tileEnt.markForUpdate();
tileEnt.markDirty();
return true;
}
public Item getItemDropped(int par1, Random random, int par3) {
return Item.getItemFromBlock(ModBlocks.forgeAnvil);
}
public Item getItem(World world, int par2, int par3, int par4) {
return Item.getItemFromBlock(ModBlocks.forgeAnvil);
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntityAnvilForge tileEnt = (TileEntityAnvilForge) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public int getRenderType() {
return RenderId.anvilForgeID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
int dir = MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3;
world.setBlockMetadataWithNotify(x, y, z, dir, 0);
//System.out.println(dir);
}
}

View File

@@ -0,0 +1,128 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileEntitySolidFilter;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
public class SolidFilter extends BlockContainer {
private final Random random = new Random();
//private NBTTagCompound nbt = new NBTTagCompound();
public SolidFilter(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.1F, 0.01F, 0.1F,
0.9F, 1.0F, 0.9F);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileEntitySolidFilter tileSand = (TileEntitySolidFilter) world.getTileEntity(x, y, z);
if (!player.isSneaking()) {
FMLNetworkHandler.openGui(player, Main.instance, 4, world, x, y, z);
return true;
}
if(player.isSneaking()){
if(tileSand.getStackInSlot(0)!=null){
int s = player.inventory.currentItem;
if((player.inventory.getStackInSlot(s)==null)){
if((world.getBlock(x, y+1, z).equals(Blocks.sand))||(world.getBlock(x, y+1, z).equals(Blocks.gravel))){
tileSand.hits++;
player.worldObj.playSoundAtEntity(player, "step.sand", 0.5F, 0.5F);
tileSand.getStackInSlot(0).setItemDamage(tileSand.getStackInSlot(0).getItemDamage()+1);
}
}
}
}
return true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntitySolidFilter tileEnt = (TileEntitySolidFilter) world.getTileEntity(x, y, z);
if (tileEnt != null) {
for (int i = 0; i < tileEnt.getSizeInventory(); ++i) {
ItemStack itemstack = tileEnt.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntitySolidFilter();
}
@Override
public int getRenderType() {
return RenderId.solidFilterID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,182 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.tileents.machine.TileEntityTestForge;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TestForge extends BlockContainer {
//private static double s= 0.25;
//private static double a=0.75;
private final Random random = new Random();
public static boolean makeIngot;
public static int ticks;
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public TestForge(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(2.0F);
this.setResistance(6.0F);
this.setStepSound(Block.soundTypeStone);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "forgeside");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "forgeside");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "forgebot");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "forgetop");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return side == 1 ? this.iconTop : (side == 0 ? this.iconBot : (side != metadata ? this.blockIcon : this.iconSide));
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityTestForge();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z,EntityPlayer player, int metadata, float what, float these, float are) {
FMLNetworkHandler.openGui(player, Main.instance, 2, world, x, y, z);
return true;
}
public Item getItemDropped(int par1, Random random, int par3) {
return null;
}
public Item getItem(World world, int par2, int par3, int par4) {
//return Item.getItemFromBlock(ModBlocks.testForge);
return null;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
super.randomDisplayTick(world, x, y, z, random);
TileEntityTestForge tileEnt = (TileEntityTestForge) world.getTileEntity(x, y, z);
/*if(tileEnt.isRunning == true){
}*/
/*Block test = world.getBlock(x, y+1, z);
if (test == TestForgeCrafting.blockToCheck.get(0) || test == TestForgeCrafting.blockToCheck.get(1) || test == TestForgeCrafting.blockToCheck.get(2)
|| test == TestForgeCrafting.blockToCheck.get(3) || test == TestForgeCrafting.blockToCheck.get(4)) {
if (world.canBlockSeeTheSky(x, y+2, z)){
for(int i = 1; i <11; i++){
//world.setBlockMetadataWithNotify(x, y, z, 1, 2);
world.spawnParticle("cloud", x + a, y+i+1, z + s, 0, 0.1F, 0);
world.spawnParticle("largesmoke", x + a, y+i+1, z + s, 0, 0.1F, 0);
world.spawnParticle("cloud", x + s, y+i+1, z + a, 0, 0.1F, 0);
world.spawnParticle("largesmoke", x + s, y+i+1, z + a, 0, 0.1F, 0);
world.spawnParticle("cloud", x + a, y+i+1, z + a, 0, 0.1F, 0);
world.spawnParticle("largesmoke", x + a, y+i+1, z + a, 0, 0.1F, 0);
world.spawnParticle("cloud", x + s, y+i+1, z + s, 0, 0.1F, 0);
world.spawnParticle("largesmoke", x + s, y+i+1, z + s, 0, 0.1F, 0);
}
}
}*/
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntityTestForge tileEntTestForge = (TileEntityTestForge) world.getTileEntity(x, y, z);
if (tileEntTestForge != null) {
for (int i = 0; i < tileEntTestForge.getSizeInventory(); ++i) {
ItemStack itemstack = tileEntTestForge.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (float) this.random.nextGaussian() * f3;
entityitem.motionY = (float) this.random.nextGaussian() * f3 + 0.1F;
entityitem.motionZ = (float) this.random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
super.breakBlock(world, x, y, z, block, meta);
}
}

View File

@@ -0,0 +1,79 @@
package com.kitsu.medievalcraft.block.machines;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.machine.TileEntityWaterFilter;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class WaterFilter extends BlockContainer {
public WaterFilter(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 1, 0);
this.setStepSound(Block.soundTypeStone);
//xmin, ymin, zmin,
//xmax, ymax, zmax
//this.setBlockBounds(0.17F, 0.0F, 0.315F,
//0.8F, 0.15F, 0.725F);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntityWaterFilter();
}
@Override
public int getRenderType() {
return RenderId.waterFilterID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
super.randomDisplayTick(world, x, y, z, random);
if((world.getBlock(x, y+1, z).equals(Blocks.water)) && world.getBlock(x, y-1, z).equals(Blocks.air)){
if (random.nextInt(8) == 0) {
world.spawnParticle("bubble", x + 0.3D, y + 1.1D, z + 0.34D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(8) == 1) {
world.spawnParticle("bubble", x + 0.3D, y + 1.1D, z + 0.34D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(8) == 2) {
world.spawnParticle("bubble", x + 0.75D, y + 1.1D, z + 0.6D, 0.0D, 0.0D, 0.0D);
}
if (random.nextInt(8) == 3) {
world.spawnParticle("bubble", x + 0.45D, y + 1.1D, z + 0.75D, 0.0D, 0.0D, 0.0D);
}
}
}
}

View File

@@ -0,0 +1,67 @@
package com.kitsu.medievalcraft.block.machines;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.gui.GuiHandler;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class formTable extends Block {
@SideOnly(Side.CLIENT)
private IIcon formTableTop;
/*
@SideOnly(Side.CLIENT)
private IIcon formTableSide; */
public formTable(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
//this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.5F);
this.setResistance(2.0F);
}
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int metadata) {
return side == 1 ? this.formTableTop : this.blockIcon;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "formTableSide");
this.formTableTop = iconRegister.registerIcon(Main.MODID + ":" + "formTableTop");
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if (!player.isSneaking()) {
player.openGui(Main.instance, GuiHandler.guiIDformTable, world, x, y, z);
return true;
}
return false;
}
}

View File

@@ -0,0 +1,59 @@
package com.kitsu.medievalcraft.block;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderEnd;
import net.minecraftforge.common.util.ForgeDirection;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
public class shitBlock extends Block {
protected shitBlock(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(2.0F);
this.setResistance(6.0F);
this.setHarvestLevel("shovel", 0);
this.setStepSound(soundTypeSnow);
this.setTickRandomly(true);
}
public void updateTick(World world, int x, int y, int z, Random random){
//System.out.println("Block Tick");
if(random.nextInt(100)==0){
//System.out.println("Random Method Fired");
//world.setBlock(x, y, z, Blocks.air, 0, 2);
world.func_147480_a(x, y, z, false);
}
}
@Override
public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side)
{
if (this == ModBlocks.shitblock && side == UP)
{
return true;
}
if ((world.provider instanceof WorldProviderEnd) && this == Blocks.bedrock && side == UP)
{
return true;
}
return false;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,249 @@
package com.kitsu.medievalcraft.block.wood;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.TileEntitySmallBarrel;
import com.kitsu.medievalcraft.util.CustomTab;
public class SmallBarrel extends BlockContainer {
public SmallBarrel(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(1.0F);
this.setResistance(1.0F);
this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeWood);
//xmin, ymin, zmin,
//xmax, ymax, zmax
this.setBlockBounds(0.125F, 0.0F, 0.125F,
0.775F, 0.8F, 0.775F);
}
//MAKE CASES AND HAVE THEM RUN ON THE CLIENT AND SERVER TO UPDATE THE PLAYERS INVENTORY I GUESS SOME SHIT LIKE THAT
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack p_149689_6_) {
TileEntitySmallBarrel tile = (TileEntitySmallBarrel) world.getTileEntity(x, y, z);
tile.res="kitsumedievalcraft:models/UntitledBarrel.png";
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
TileEntitySmallBarrel tile = (TileEntitySmallBarrel) world.getTileEntity(x, y, z);
//if(!world.isRemote){
/*if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem().getItem()==ModItems.itemSmallBarrelLid){
if(tile.lid==false){
player.swingItem();
player.inventory.decrStackSize(player.inventory.currentItem, 1);
tile.lid=true;
if(tile.quanta==0){
tile.type="empty";
}
tile.markForUpdate();
tile.markDirty();
return true;
}
}
}*/
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem().getItem()==ModItems.soakedLeather){
if((tile.scuddedloaded==false)&&(tile.soakedloaded==false)){
player.inventory.decrStackSize(player.inventory.currentItem, 1);
tile.soakedloaded=true;
tile.markForUpdate();
tile.markDirty();
return true;
}
}
}
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem().getItem()==ModItems.scuddedLeather){
if((tile.scuddedloaded==false)&&(tile.soakedloaded==false)){
player.inventory.decrStackSize(player.inventory.currentItem, 1);
tile.scuddedloaded=true;
tile.markForUpdate();
tile.markDirty();
return true;
}
}
}
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem().getItem()==ModItems.tanninBucket){
//if(tile.lid==false){
if((tile.type.equals("empty"))||(tile.type.equals("tannin"))){
tile.type = "tannin";
if(tile.quanta < 2){
ItemStack bucket = new ItemStack(Items.bucket, 1);
tile.quanta = tile.quanta+1;
player.inventory.decrStackSize(player.inventory.currentItem, 1);
player.inventory.addItemStackToInventory(bucket);
if(tile.quanta==1){
tile.res = "kitsumedievalcraft:models/UntitledBarrelTan1.png";
}
if(tile.quanta==2){
tile.res = "kitsumedievalcraft:models/UntitledBarrelTan2.png";
}
tile.markForUpdate();
tile.markDirty();
return true;
}
}
//}
}
}
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem().getItem()==ModItems.slackBucket){
//if(tile.lid==false){
if((tile.type.equals("empty"))||(tile.type.equals("slack"))){
tile.type = "slack";
if(tile.quanta < 2){
ItemStack bucket = new ItemStack(Items.bucket, 1);
tile.quanta = tile.quanta+1;
player.inventory.decrStackSize(player.inventory.currentItem, 1);
player.inventory.addItemStackToInventory(bucket);
if(tile.quanta==1){
tile.res = "kitsumedievalcraft:models/UntitledBarrelSlack1.png";
}
if(tile.quanta==2){
tile.res = "kitsumedievalcraft:models/UntitledBarrelSlack2.png";
}
tile.markForUpdate();
tile.markDirty();
return true;
}
}
//}
}
}
if(player.inventory.getCurrentItem()!=null){
if(player.inventory.getCurrentItem().getItem()==Items.bucket){
//if(tile.lid==false){
if(tile.quanta>0){
if(tile.type.equals("tannin")){
tile.quanta--;
ItemStack bucket = new ItemStack(ModItems.tanninBucket);
player.inventory.addItemStackToInventory(bucket);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
if(tile.quanta==0){
tile.type="empty";
tile.res="kitsumedievalcraft:models/UntitledBarrel.png";
}
if(tile.quanta==1){
tile.res="kitsumedievalcraft:models/UntitledBarrelTan1.png";
}
tile.markForUpdate();
tile.markDirty();
return true;
}
if(tile.type.equals("slack")){
tile.quanta--;
ItemStack bucket = new ItemStack(ModItems.slackBucket);
player.inventory.addItemStackToInventory(bucket);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
if(tile.quanta==0){
tile.type ="empty";
tile.res="kitsumedievalcraft:models/UntitledBarrel.png";
}
if(tile.quanta==1){
tile.res="kitsumedievalcraft:models/UntitledBarrelSlack1.png";
}
tile.markForUpdate();
tile.markDirty();
return true;
}
}
//}
}
}
if(player.inventory.getCurrentItem()==null){
/*if(tile.lid==true){
ItemStack lid = new ItemStack(ModItems.itemSmallBarrelLid, 1);
//player.swingItem();
//int p = player.inventory.getFirstEmptyStack();
tile.lid=false;
player.inventory.addItemStackToInventory(lid);
//player.inventory.setInventorySlotContents(p, lid);
tile.markForUpdate();
tile.markDirty();
return true;
}*/
//if(tile.lid==false){
if(tile.scuddedready==true){
ItemStack tanned = new ItemStack(ModItems.tannedLeather, 1);
player.inventory.addItemStackToInventory(tanned);
tile.scuddedready=false;
tile.scuddedloaded=false;
tile.markForUpdate();
tile.markDirty();
return true;
}
//}
//if(tile.lid==false){
if(tile.soakedready==true){
ItemStack slacked = new ItemStack(ModItems.slackedLeather, 1);
player.inventory.addItemStackToInventory(slacked);
tile.soakedready=false;
tile.soakedloaded=false;
tile.markForUpdate();
tile.markDirty();
return true;
}
//}
//if(tile.lid==false){
if((tile.soakedready==false)&&(tile.scuddedready==false)){
world.setBlockToAir(x, y, z);
ItemStack barrel = new ItemStack(ModBlocks.smallBarrel, 1);
player.inventory.addItemStackToInventory(barrel);
tile.markForUpdate();
tile.markDirty();
return true;
}
//}
}
tile.markForUpdate();
tile.markDirty();
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntitySmallBarrel();
}
@Override
public int getRenderType() {
return RenderId.smallBarrelID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,115 @@
package com.kitsu.medievalcraft.block.wood;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.renderer.RenderId;
import com.kitsu.medievalcraft.tileents.TileEntitySmallLid;
public class SmallBarrelLid extends BlockContainer {
public SmallBarrelLid(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
//this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(1.0F);
this.setResistance(1.0F);
this.setHarvestLevel(null, 0);
this.setStepSound(soundTypeWood);
//xmin, ymin, zmin,
//xmax, ymax, zmax
//this.setBlockBounds(0.17F, 0.0F, 0.315F,
// 0.8F, 0.15F, 0.725F);
}
@Override
public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_){
if(!world.isRemote){
TileEntitySmallLid tileLid = (TileEntitySmallLid) world.getTileEntity(x, y, z);
if(tileLid.ring<2){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModItems.itemSmallBarrelLid, 1, 0)));
//System.out.println(world.getTileEntity(x, y, z));
//System.out.println(tileLid.logs);
if(tileLid.logs>0){
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModItems.halfSplitBoard, tileLid.logs, 0)));
}
}
}
super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_);
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return null;
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(!world.isRemote){
TileEntitySmallLid tileLid = (TileEntitySmallLid) world.getTileEntity(x, y, z);
if(player.inventory.getCurrentItem()!=null){
if((player.getCurrentEquippedItem().getItem().equals(ModItems.halfSplitBoard))){
if(tileLid.logs<8){
player.inventory.decrStackSize(player.inventory.currentItem, 1);
tileLid.logs = tileLid.logs +1;
world.markBlockForUpdate(x, y, z);
return true;
}
}
}
if(player.inventory.getCurrentItem()!=null){
if((player.getCurrentEquippedItem().getItem().equals(ModItems.saplingRing))){
if(tileLid.logs==8){
player.inventory.decrStackSize(player.inventory.currentItem, 1);
tileLid.ring = tileLid.ring +1;
if(tileLid.ring==2){
world.markBlockForUpdate(x, y, z);
return true;
}
}
}
}
}
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntitySmallLid();
}
@Override
public int getRenderType() {
return RenderId.smallLidID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -0,0 +1,112 @@
package com.kitsu.medievalcraft.block.wood.clean;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CleanAcacia extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public CleanAcacia(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
player.swingItem();
if(world.rand.nextInt(4)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.acaciaSplitLog, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
int j1 = p_149660_9_ & 3;
byte b0 = 0;
switch (p_149660_5_)
{
case 0:
case 1:
b0 = 0;
break;
case 2:
case 3:
b0 = 8;
break;
case 4:
case 5:
b0 = 4;
}
return j1 | b0;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "cleanAcaciaSide");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "cleanAcaciaSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "cleanAcaciaTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "cleanAcaciaTop");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
}

View File

@@ -0,0 +1,113 @@
package com.kitsu.medievalcraft.block.wood.clean;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CleanBirch extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public CleanBirch(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
player.swingItem();
if(world.rand.nextInt(4)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.birchSplitLog, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
int j1 = p_149660_9_ & 3;
byte b0 = 0;
switch (p_149660_5_)
{
case 0:
case 1:
b0 = 0;
break;
case 2:
case 3:
b0 = 8;
break;
case 4:
case 5:
b0 = 4;
}
return j1 | b0;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "cleanBirchSide");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "cleanBirchSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "cleanBirchTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "cleanBirchTop");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
}

View File

@@ -0,0 +1,114 @@
package com.kitsu.medievalcraft.block.wood.clean;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CleanDarkOak extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public CleanDarkOak(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
player.swingItem();
if(world.rand.nextInt(4)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.darkSplitLog, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
int j1 = p_149660_9_ & 3;
byte b0 = 0;
switch (p_149660_5_)
{
case 0:
case 1:
b0 = 0;
break;
case 2:
case 3:
b0 = 8;
break;
case 4:
case 5:
b0 = 4;
}
return j1 | b0;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "cleanDarkOakSide");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "cleanDarkOakSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "cleanDarkOakTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "cleanDarkOakTop");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
}

View File

@@ -0,0 +1,113 @@
package com.kitsu.medievalcraft.block.wood.clean;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CleanJungle extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public CleanJungle(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
player.swingItem();
if(world.rand.nextInt(4)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.jungleSplitLog, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
int j1 = p_149660_9_ & 3;
byte b0 = 0;
switch (p_149660_5_)
{
case 0:
case 1:
b0 = 0;
break;
case 2:
case 3:
b0 = 8;
break;
case 4:
case 5:
b0 = 4;
}
return j1 | b0;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "cleanJungleSide");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "cleanJungleSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "cleanJungleTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "cleanJungleTop");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
}

View File

@@ -0,0 +1,113 @@
package com.kitsu.medievalcraft.block.wood.clean;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CleanOak extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public CleanOak(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
player.swingItem();
if(world.rand.nextInt(4)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.oakSplitLog, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
int j1 = p_149660_9_ & 3;
byte b0 = 0;
switch (p_149660_5_)
{
case 0:
case 1:
b0 = 0;
break;
case 2:
case 3:
b0 = 8;
break;
case 4:
case 5:
b0 = 4;
}
return j1 | b0;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "cleanOakSide");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "cleanOakSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "cleanOakTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "cleanOakTop");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
}

View File

@@ -0,0 +1,114 @@
package com.kitsu.medievalcraft.block.wood.clean;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CleanSpruce extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public CleanSpruce(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
player.swingItem();
if(world.rand.nextInt(4)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModBlocks.spruceSplitLog, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
int j1 = p_149660_9_ & 3;
byte b0 = 0;
switch (p_149660_5_)
{
case 0:
case 1:
b0 = 0;
break;
case 2:
case 3:
b0 = 8;
break;
case 4:
case 5:
b0 = 4;
}
return j1 | b0;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "cleanSpruceSide");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "cleanSpruceSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "cleanSpruceTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "cleanSpruceTop");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
}

View File

@@ -0,0 +1,189 @@
package com.kitsu.medievalcraft.block.wood.quartersplit;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class AcaciaSplitLog extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon blockIcon;
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public AcaciaSplitLog(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "cleanAcaciaSide");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "acaciaSplitLogSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "acaciaSplitLogTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "acaciaSplitLogTop");
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
player.swingItem();
if(world.rand.nextInt(2)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModItems.splitBoard, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitx, float hity, float hitz, int meta)
{
//System.out.println(side);
int j1 = meta & 3;
byte b0 = 0;
switch (side)
{
case 0:
b0=0;
break;
case 1:
b0=0;
break;
case 2:
b0=8;
break;
case 3:
b0=8;
break;
case 4:
b0=4;
case 5:
b0=4;
}
return j1 | b0;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
this.func_149797_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_));
}
/**
* Returns the bounding box of the wired rectangular prism to render.
*/
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_)
{
this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
}
public void func_149797_b(int p_149797_1_)
{
if (p_149797_1_ == 0)
{
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
if (p_149797_1_ == 4)
{
this.setBlockBounds(0.0F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F);
}
if (p_149797_1_ == 8)
{
this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 1.0F);
//this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side)
{
return true;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
}

View File

@@ -0,0 +1,188 @@
package com.kitsu.medievalcraft.block.wood.quartersplit;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BirchSplitLog extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon blockIcon;
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public BirchSplitLog(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "cleanBirchSide");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "birchSplitLogSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "birchSplitLogTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "birchSplitLogTop");
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.swingItem();
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
if(world.rand.nextInt(2)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModItems.splitBoard, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitx, float hity, float hitz, int meta)
{
//System.out.println(side);
int j1 = meta & 3;
byte b0 = 0;
switch (side)
{
case 0:
b0=0;
break;
case 1:
b0=0;
break;
case 2:
b0=8;
break;
case 3:
b0=8;
break;
case 4:
b0=4;
case 5:
b0=4;
}
return j1 | b0;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
this.func_149797_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_));
}
/**
* Returns the bounding box of the wired rectangular prism to render.
*/
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_)
{
this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
}
public void func_149797_b(int p_149797_1_)
{
if (p_149797_1_ == 0)
{
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
if (p_149797_1_ == 4)
{
this.setBlockBounds(0.0F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F);
}
if (p_149797_1_ == 8)
{
this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 1.0F);
//this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
//this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side)
{
return true;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
}

View File

@@ -0,0 +1,184 @@
package com.kitsu.medievalcraft.block.wood.quartersplit;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class DarkSplitLog extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public DarkSplitLog(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "darkSplitLogIcon");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "darkSplitLogSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "darkSplitLogTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "darkSplitLogTop");
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.swingItem();
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
if(world.rand.nextInt(2)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModItems.splitBoard, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitx, float hity, float hitz, int meta)
{
//System.out.println(side);
int j1 = meta & 3;
byte b0 = 0;
switch (side)
{
case 0:
b0=0;
break;
case 1:
b0=0;
break;
case 2:
b0=8;
break;
case 3:
b0=8;
break;
case 4:
b0=4;
case 5:
b0=4;
}
return j1 | b0;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
this.func_149797_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_));
}
/**
* Returns the bounding box of the wired rectangular prism to render.
*/
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_)
{
this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
}
public void func_149797_b(int p_149797_1_)
{
if (p_149797_1_ == 0)
{
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
if (p_149797_1_ == 4)
{
this.setBlockBounds(0.0F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F);
}
if (p_149797_1_ == 8)
{
this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 1.0F);
//this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
//this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side)
{
return true;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
}

View File

@@ -0,0 +1,186 @@
package com.kitsu.medievalcraft.block.wood.quartersplit;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class JungleSplitLog extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public JungleSplitLog(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "jungleSplitLogIcon");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "jungleSplitLogSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "jungleSplitLogTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "jungleSplitLogTop");
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.swingItem();
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
if(world.rand.nextInt(2)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModItems.splitBoard, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitx, float hity, float hitz, int meta)
{
//System.out.println(side);
int j1 = meta & 3;
byte b0 = 0;
switch (side)
{
case 0:
b0=0;
break;
case 1:
b0=0;
break;
case 2:
b0=8;
break;
case 3:
b0=8;
break;
case 4:
b0=4;
case 5:
b0=4;
}
return j1 | b0;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
this.func_149797_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_));
}
/**
* Returns the bounding box of the wired rectangular prism to render.
*/
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_)
{
this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
}
public void func_149797_b(int p_149797_1_)
{
if (p_149797_1_ == 0)
{
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
if (p_149797_1_ == 4)
{
this.setBlockBounds(0.0F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F);
}
if (p_149797_1_ == 8)
{
this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 1.0F);
//this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side)
{
return true;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
}

View File

@@ -0,0 +1,186 @@
package com.kitsu.medievalcraft.block.wood.quartersplit;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class OakSplitLog extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public OakSplitLog(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "oakSplitLogIcon");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "oakSplitLogSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "oakSplitLogTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "oakSplitLogTop");
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.swingItem();
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
if(world.rand.nextInt(2)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModItems.splitBoard, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitx, float hity, float hitz, int meta)
{
//System.out.println(side);
int j1 = meta & 3;
byte b0 = 0;
switch (side)
{
case 0:
b0=0;
break;
case 1:
b0=0;
break;
case 2:
b0=8;
break;
case 3:
b0=8;
break;
case 4:
b0=4;
case 5:
b0=4;
}
return j1 | b0;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
this.func_149797_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_));
}
/**
* Returns the bounding box of the wired rectangular prism to render.
*/
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_)
{
this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
}
public void func_149797_b(int p_149797_1_)
{
if (p_149797_1_ == 0)
{
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
if (p_149797_1_ == 4)
{
this.setBlockBounds(0.0F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F);
}
if (p_149797_1_ == 8)
{
this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 1.0F);
//this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side)
{
return true;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
}

View File

@@ -0,0 +1,185 @@
package com.kitsu.medievalcraft.block.wood.quartersplit;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRotatedPillar;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class SpruceSplitLog extends BlockRotatedPillar {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBot;
public SpruceSplitLog(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.MODID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.MedievalCraftTab);
this.setHardness(3.0F);
this.setResistance(3.0F);
this.setStepSound(Block.soundTypeWood);
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(Main.MODID + ":" + "spruceSplitLogIcon");
this.iconSide = iconRegister.registerIcon(Main.MODID + ":" + "spruceSplitLogSide");
this.iconBot = iconRegister.registerIcon(Main.MODID + ":" + "spruceSplitLogTop");
this.iconTop = iconRegister.registerIcon(Main.MODID + ":" + "spruceSplitLogTop");
}
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int q, float a, float b, float c) {
if(player.inventory.getCurrentItem()!=null){
if(player.getCurrentEquippedItem().getItem() instanceof ItemAxe){
player.swingItem();
player.worldObj.playSoundAtEntity(player, Main.MODID + ":splitlog", 1.0F, 1.0F);
if(world.rand.nextInt(2)==0){
if(!world.isRemote){
world.setBlock(x, y, z, Blocks.air, 0, 2);
world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(ModItems.splitBoard, 4, 0)));
return true;
}
}
}
}
return false;
}
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitx, float hity, float hitz, int meta)
{
//System.out.println(side);
int j1 = meta & 3;
byte b0 = 0;
switch (side)
{
case 0:
b0=0;
break;
case 1:
b0=0;
break;
case 2:
b0=8;
break;
case 3:
b0=8;
break;
case 4:
b0=4;
case 5:
b0=4;
}
return j1 | b0;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
this.func_149797_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_));
}
/**
* Returns the bounding box of the wired rectangular prism to render.
*/
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_)
{
this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_);
}
public void func_149797_b(int p_149797_1_)
{
if (p_149797_1_ == 0)
{
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 1.0F, 0.75F);
}
if (p_149797_1_ == 4)
{
this.setBlockBounds(0.0F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F);
}
if (p_149797_1_ == 8)
{
this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 1.0F);
//this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
int k = metadata & 12;
int l = metadata & 3;
return k == 0 && (side == 1 || side == 0) ? this.getTopIcon(l) : (k == 4 && (side == 5 || side == 4) ? this.getTopIcon(l) : (k == 8 && (side == 2 || side == 3) ? this.getTopIcon(l) : this.getSideIcon(l)));
}
@SideOnly(Side.CLIENT)
protected IIcon getSideIcon(int p_150163_1_)
{
return this.iconSide;
}
@SideOnly(Side.CLIENT)
protected IIcon getTopIcon(int p_150161_1_)
{
return this.iconTop;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess access, int x, int y, int z, int side)
{
return true;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
}

View File

@@ -0,0 +1,27 @@
package com.kitsu.medievalcraft.compat;
import net.minecraft.item.ItemStack;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.item.ModItems;
import cpw.mods.fml.common.IFuelHandler;
public class FuelHandler implements IFuelHandler
{
@Override
public int getBurnTime(ItemStack fuel)
{
ItemStack stack = fuel;
//MagnumOpus.logger.info("fuel handler: " + fuel);
/** Mod Real Fuel Items **/
if ( stack.isItemEqual(new ItemStack(ModItems.itemShit)) ) { return 150; }
else if ( stack.isItemEqual(new ItemStack(ModBlocks.shitblock)) ) { return 1500; }
/** that is all **/
else { return 0; }
}
}

View File

@@ -0,0 +1,52 @@
package com.kitsu.medievalcraft.compat;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.item.ModItems;
public class ModDict {
public static void RegisterOres () {
//OreDictionary.registerOre("itemLeather", Items.leather);
OreDictionary.registerOre("strapLeather", new ItemStack(ModItems.leatherStrap, 1, 0));
OreDictionary.registerOre("ringIron", new ItemStack(ModItems.ironRing, 1, 0));
OreDictionary.registerOre("ingotIron", new ItemStack(ModBlocks.refinedIron, 1, 0));
OreDictionary.registerOre("nuggetIron", new ItemStack(ModItems.ironChunk, 1, 0));
OreDictionary.registerOre("ingotSteel", new ItemStack(ModBlocks.damascus, 1, 0));
OreDictionary.registerOre("materialHardenedLeather", new ItemStack(ModItems.finishedLeather, 1, 0));
OreDictionary.registerOre("bladeTool", new ItemStack(ModItems.workBlade, 1, 0));
OreDictionary.registerOre("foodSalt", new ItemStack(ModItems.salt, 1, 0));
OreDictionary.registerOre("pulpWood", new ItemStack(ModItems.woodPulp, 1, 0));
OreDictionary.registerOre("knappedFlint", new ItemStack(ModItems.flintKnapped, 1, 0));
OreDictionary.registerOre("blockClay", new ItemStack(Blocks.clay, 1, 0));
OreDictionary.registerOre("clumpClay", new ItemStack(Items.clay_ball, 1, 0));
OreDictionary.registerOre("clumpFuel", new ItemStack(ModBlocks.shitblock, 1, 0));
OreDictionary.registerOre("ingotBrickClay", new ItemStack(Items.brick, 1, 0));
OreDictionary.registerOre("cordageStrong", new ItemStack(Items.string, 1, 0));
//OreDictionary.registerOre("cordage", new ItemStack(ModItems.leatherString, 1, 0));
//OreDictionary.registerOre("itemLeather", ModItems.cutLeather);
//OreDictionary.replacements.put(new ItemStack(Item.leather), "itemLeather");
//OreDictionary.registerOre("strapLeather", new ItemStack(ModItems.leatherStrap));
}
}
/*
*
* OreDictionary.registerOre("foodSalt", new ItemStack(ModItems.saltRock, 1, 0));
OreDictionary.registerOre("foodSalt", new ItemStack(ModItems.saltFire, 1, 0));
OreDictionary.registerOre("foodSalt", new ItemStack(ModItems.saltVoid, 1, 0));
OreDictionary.registerOre("foodSalt", new ItemStack(ModItems.saltNetjry, 1, 0));
*
*/

View File

@@ -0,0 +1,81 @@
package com.kitsu.medievalcraft.contain;
import com.kitsu.medievalcraft.tileents.cannon.TileCannon_28;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerCannon_28 extends Container {
protected TileCannon_28 tileEnt;
@Override
public boolean canInteractWith(EntityPlayer player) {
return tileEnt.isUseableByPlayer(player);
}
public ContainerCannon_28 (InventoryPlayer inventoryPlayer, TileCannon_28 te){
tileEnt = te;
//the Slot constructor takes the IInventory and the slot number in that it binds to
//and the x-y coordinates it resides on-screen
/* for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
addSlotToContainer(new Slot(tileEnt, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}*/
addSlotToContainer(new Slot(tileEnt, 0, 30, 34));
addSlotToContainer(new Slot(tileEnt, 1, 48, 34));
//commonly used vanilla code that adds the player's inventory
bindPlayerInventory(inventoryPlayer);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
//null checks and checks if the item can be stacked (maxStackSize > 1)
/*if (slotObject != null && slotObject.getHasStack()) {
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
//merges the item into player inventory since its in the tileEntity
if (slot < 9) {
if (!this.mergeItemStack(stackInSlot, 9, this.inventorySlots.size(), true)) {
return null;
}
}
//places it into the tileEntity is possible since its in the player inventory
else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
return null;
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack((ItemStack)null);
} else {
slotObject.onSlotChanged();
}
}*/
return stack;
}
}

View File

@@ -0,0 +1,63 @@
package com.kitsu.medievalcraft.contain;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.kitsu.medievalcraft.tileents.machine.TileEntityAnvilForge;
import com.kitsu.medievalcraft.tileents.machine.TileEntityFirebox;
import com.kitsu.medievalcraft.tileents.machine.TileEntityShelfFour;
public class ContainerFirebox extends Container {
protected TileEntityFirebox tileEnt;
@Override
public boolean canInteractWith(EntityPlayer player) {
return tileEnt.isUseableByPlayer(player);
}
public ContainerFirebox (InventoryPlayer inventoryPlayer, TileEntityFirebox te){
tileEnt = te;
addSlotToContainer(new Slot(tileEnt, 0, 80, 34));
bindPlayerInventory(inventoryPlayer);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
if (slotObject != null && slotObject.getHasStack()) {
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if (slot < 9) {
if (!this.mergeItemStack(stackInSlot, 9, this.inventorySlots.size(), true)) {
return null;
}
}
else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
return null;
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack((ItemStack)null);
} else {
slotObject.onSlotChanged();
}
}
return stack;
}
}

View File

@@ -0,0 +1,85 @@
package com.kitsu.medievalcraft.contain;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.kitsu.medievalcraft.tileents.machine.TileEntityFirebox;
import com.kitsu.medievalcraft.tileents.machine.TileForge;
public class ContainerForge extends Container {
protected TileForge tileEnt;
@Override
public boolean canInteractWith(EntityPlayer player) {
return tileEnt.isUseableByPlayer(player);
}
public ContainerForge (InventoryPlayer inventoryPlayer, TileForge te){
tileEnt = te;
//the Slot constructor takes the IInventory and the slot number in that it binds to
//and the x-y coordinates it resides on-screen
/* for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
addSlotToContainer(new Slot(tileEnt, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}*/
addSlotToContainer(new Slot(tileEnt, 0, 80, 34));
addSlotToContainer(new Slot(tileEnt, 0, 81, 34));
//commonly used vanilla code that adds the player's inventory
bindPlayerInventory(inventoryPlayer);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
//null checks and checks if the item can be stacked (maxStackSize > 1)
if (slotObject != null && slotObject.getHasStack()) {
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
//merges the item into player inventory since its in the tileEntity
if (slot < 9) {
if (!this.mergeItemStack(stackInSlot, 9, this.inventorySlots.size(), true)) {
return null;
}
}
//places it into the tileEntity is possible since its in the player inventory
else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
return null;
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack((ItemStack)null);
} else {
slotObject.onSlotChanged();
}
/*if (stackInSlot.stackSize == stack.stackSize) {
return null;
}*/
//slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
}

View File

@@ -0,0 +1,62 @@
package com.kitsu.medievalcraft.contain;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.kitsu.medievalcraft.tileents.machine.TileEntityAnvilForge;
import com.kitsu.medievalcraft.tileents.machine.TileEntityFirebox;
public class ContainerForgeAnvil extends Container {
protected TileEntityAnvilForge tileEnt;
@Override
public boolean canInteractWith(EntityPlayer player) {
return tileEnt.isUseableByPlayer(player);
}
public ContainerForgeAnvil (InventoryPlayer inventoryPlayer, TileEntityAnvilForge te){
tileEnt = te;
addSlotToContainer(new Slot(tileEnt, 0, 80, 34));
bindPlayerInventory(inventoryPlayer);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
if (slotObject != null && slotObject.getHasStack()) {
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if (slot < 9) {
if (!this.mergeItemStack(stackInSlot, 9, this.inventorySlots.size(), true)) {
return null;
}
}
else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
return null;
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack((ItemStack)null);
} else {
slotObject.onSlotChanged();
}
}
return stack;
}
}

View File

@@ -0,0 +1,146 @@
package com.kitsu.medievalcraft.contain;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.crafting.FormTableCraftManager;
public class ContainerFormTable extends Container {
public InventoryCrafting craftMatrix;
public IInventory craftResult;
private World worldObj;
private int posX;
private int posY;
private int posZ;
public ContainerFormTable (InventoryPlayer invplayer, World world, int x, int y, int z) {
craftMatrix = new InventoryCrafting (this, 5, 5);
craftResult = new InventoryCraftResult();
worldObj = world;
posX = x;
posY = y;
posZ = z;
this.addSlotToContainer(new SlotCrafting(invplayer.player, craftMatrix, craftResult, 0, 141, 43));
for(int i=0; i<5; i++) {
for (int k=0; k<5; k++) {
this.addSlotToContainer (new Slot(craftMatrix, k+i*5, 8+k*18, 7+i*18));
}
}
for(int i=0; i<3; i++) {
for (int k=0; k<9; k++) {
this.addSlotToContainer (new Slot(invplayer, k+i*9+9, 8+k*18, 106+i*18));
}
}
for(int i=0; i<9; i++) {
this.addSlotToContainer (new Slot(invplayer, i, 8+i*18, 164));
}
onCraftMatrixChanged(craftMatrix);
}
public void onCraftMatrixChanged (IInventory iinventory) {
craftResult.setInventorySlotContents(0,FormTableCraftManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
}
@Override
public boolean canInteractWith(EntityPlayer player) {
if (worldObj.getBlock(posX, posY, posZ) != ModBlocks.formtable) {
return false;
}
return player.getDistanceSq(posX + 0.5D, posY + 0.5D, posZ + 0.5D) <= 64.0D;
}
/**
* Called when the container is closed.
*/
/*public void onContainerClosed(EntityPlayer player)
{
super.onContainerClosed(player);
if (!this.worldObj.isRemote)
{
for (int i = 0; i < 25; ++i)
{
ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);
if (itemstack != null)
{
player.dropPlayerItemWithRandomChoice(itemstack, false);
}
}
}
}*/
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_)
{
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(p_82846_2_);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (p_82846_2_ == 0)
{
if (!this.mergeItemStack(itemstack1, 10, 46, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (p_82846_2_ >= 10 && p_82846_2_ < 37)
{
if (!this.mergeItemStack(itemstack1, 37, 46, false))
{
return null;
}
}
else if (p_82846_2_ >= 37 && p_82846_2_ < 46)
{
if (!this.mergeItemStack(itemstack1, 10, 37, false))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 10, 46, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
{
return null;
}
slot.onPickupFromSlot(p_82846_1_, itemstack1);
}
return itemstack;
}
}

View File

@@ -0,0 +1,85 @@
package com.kitsu.medievalcraft.contain;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.kitsu.medievalcraft.tileents.machine.TileEntityAnvilForge;
import com.kitsu.medievalcraft.tileents.machine.TileEntityShelfFour;
public class ContainerShelfFour extends Container {
protected TileEntityShelfFour tileEnt;
@Override
public boolean canInteractWith(EntityPlayer player) {
return tileEnt.isUseableByPlayer(player);
}
public ContainerShelfFour (InventoryPlayer inventoryPlayer, TileEntityShelfFour te){
tileEnt = te;
//the Slot constructor takes the IInventory and the slot number in that it binds to
//and the x-y coordinates it resides on-screen
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
addSlotToContainer(new Slot(tileEnt, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}
// addSlotToContainer(new Slot(tileEnt, 0, 80, 34));
//commonly used vanilla code that adds the player's inventory
bindPlayerInventory(inventoryPlayer);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
//null checks and checks if the item can be stacked (maxStackSize > 1)
if (slotObject != null && slotObject.getHasStack()) {
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
//merges the item into player inventory since its in the tileEntity
if (slot < 9) {
if (!this.mergeItemStack(stackInSlot, 9, this.inventorySlots.size(), true)) {
return null;
}
}
//places it into the tileEntity is possible since its in the player inventory
else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
return null;
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack((ItemStack)null);
} else {
slotObject.onSlotChanged();
}
/*if (stackInSlot.stackSize == stack.stackSize) {
return null;
}*/
//slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
}

View File

@@ -0,0 +1,95 @@
package com.kitsu.medievalcraft.contain;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.kitsu.medievalcraft.tileents.machine.TileEntitySolidFilter;
public class ContainerSolidFilter extends Container {
protected TileEntitySolidFilter tileEnt;
@Override
public boolean canInteractWith(EntityPlayer player) {
return tileEnt.isUseableByPlayer(player);
}
public ContainerSolidFilter (InventoryPlayer inventoryPlayer, TileEntitySolidFilter te){
tileEnt = te;
//the Slot constructor takes the IInventory and the slot number in that it binds to
//and the x-y coordinates it resides on-screen
/*for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
addSlotToContainer(new Slot(tileEnt, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}*/
addSlotToContainer(new Slot(tileEnt, 0, 80, 34));
//commonly used vanilla code that adds the player's inventory
bindPlayerInventory(inventoryPlayer);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
//null checks and checks if the item can be stacked (maxStackSize > 1)
if (slotObject != null && slotObject.getHasStack()) {
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
//merges the item into player inventory since its in the tileEntity
if (slot < 9) {
if (!this.mergeItemStack(stackInSlot, 9, this.inventorySlots.size(), true)) {
return null;
}
}
//places it into the tileEntity is possible since its in the player inventory
else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
return null;
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack((ItemStack)null);
} else {
slotObject.onSlotChanged();
}
/*if (stackInSlot.stackSize == stack.stackSize) {
return null;
}*/
//slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
}

View File

@@ -0,0 +1,95 @@
package com.kitsu.medievalcraft.contain;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.kitsu.medievalcraft.tileents.machine.TileEntityTestForge;
public class ContainerTestForge extends Container {
protected TileEntityTestForge tileEnt;
@Override
public boolean canInteractWith(EntityPlayer player) {
return tileEnt.isUseableByPlayer(player);
}
public ContainerTestForge (InventoryPlayer inventoryPlayer, TileEntityTestForge te){
tileEnt = te;
//the Slot constructor takes the IInventory and the slot number in that it binds to
//and the x-y coordinates it resides on-screen
/*for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
addSlotToContainer(new Slot(tileEnt, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}*/
addSlotToContainer(new Slot(tileEnt, 0, 80, 34));
//commonly used vanilla code that adds the player's inventory
bindPlayerInventory(inventoryPlayer);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
//null checks and checks if the item can be stacked (maxStackSize > 1)
if (slotObject != null && slotObject.getHasStack()) {
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
//merges the item into player inventory since its in the tileEntity
if (slot < 9) {
if (!this.mergeItemStack(stackInSlot, 9, this.inventorySlots.size(), true)) {
return null;
}
}
//places it into the tileEntity is possible since its in the player inventory
else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
return null;
}
if (stackInSlot.stackSize == 0) {
slotObject.putStack((ItemStack)null);
} else {
slotObject.onSlotChanged();
}
/*if (stackInSlot.stackSize == stack.stackSize) {
return null;
}*/
//slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
}

View File

@@ -0,0 +1,190 @@
package com.kitsu.medievalcraft.crafting;
import net.minecraft.item.ItemStack;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.item.ModItems;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
public class CraftingHandle {
public static int craftflag;
//ItemStack j;
//ItemStack R;
@SubscribeEvent
public void onItemCrafting(PlayerEvent.ItemCraftedEvent event) {
for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) { // Checks all the slots
if (event.craftMatrix.getStackInSlot(i) != null) { // If there is an item
//ItemStack a = event.craftMatrix.getStackInSlot(i);
ItemStack j = event.craftMatrix.getStackInSlot(i); // Gets the item
//ItemStack L = event.craftMatrix.getStackInSlot(i - 1);
//ItemStack R = event.craftMatrix.getStackInSlot(i+3);
//FORGE HAMMER
if (j.getItem() != null && j.getItem() == ModItems.forgeHammer) {
ItemStack k = new ItemStack(ModItems.forgeHammer, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
event.player.worldObj.playSoundAtEntity(event.player, "random.anvil_use", 0.8F, 1.0F );
//IRONSAW
} if (j.getItem() != null && j.getItem() == ModItems.ironSaw) {
ItemStack k = new ItemStack(ModItems.ironSaw, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.player.worldObj.playSoundAtEntity(event.player, Main.MODID + ":sawwood", 0.1F, 2.0F);
event.craftMatrix.setInventorySlotContents(i, k);
//FLINTSAW
} if (j.getItem() != null && j.getItem() == ModItems.flintSaw) {
ItemStack k = new ItemStack(ModItems.flintSaw, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.player.worldObj.playSoundAtEntity(event.player, Main.MODID + ":sawwood", 0.1F, 3.0F);
event.craftMatrix.setInventorySlotContents(i, k);
//WORKBLADE
} if (j.getItem() != null && j.getItem() == ModItems.workBlade) {
ItemStack k = new ItemStack(ModItems.workBlade, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON AXE FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironAxeForm) {
ItemStack k = new ItemStack(ModItems.ironAxeForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON BATTLE AXE FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironBattleAxeForm) {
ItemStack k = new ItemStack(ModItems.ironBattleAxeForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON DAGGER FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironDaggerForm) {
ItemStack k = new ItemStack(ModItems.ironDaggerForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON HALBERD FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironHandleForm) {
ItemStack k = new ItemStack(ModItems.ironHandleForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON HOE FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironHoeForm) {
ItemStack k = new ItemStack(ModItems.ironHoeForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON LONGSWORD FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironLongswordForm) {
ItemStack k = new ItemStack(ModItems.ironLongswordForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON MACE HEAD FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironMaceHeadForm) {
ItemStack k = new ItemStack(ModItems.ironMaceHeadForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON PICKAXE FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironPickaxeForm) {
ItemStack k = new ItemStack(ModItems.ironPickaxeForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON RING FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironRingForm) {
ItemStack k = new ItemStack(ModItems.ironRingForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON SAWBLADE FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironSawBladeForm) {
ItemStack k = new ItemStack(ModItems.ironSawBladeForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON SHARP TIP FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironSharpTipForm) {
ItemStack k = new ItemStack(ModItems.ironSharpTipForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON SHORT SWORD FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironShortSwordForm) {
ItemStack k = new ItemStack(ModItems.ironShortSwordForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON SPADE FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironSpadForm) {
ItemStack k = new ItemStack(ModItems.ironSpadForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//IRON SPEAR TIP FORM
} if (j.getItem() != null && j.getItem() == ModItems.ironSpearTipForm) {
ItemStack k = new ItemStack(ModItems.ironSpearTipForm, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
//LEATHER SHEARS
} if (j.getItem() != null && j.getItem() == ModItems.leatherShears) {
ItemStack k = new ItemStack(ModItems.leatherShears, 2, (j.getItemDamage() + 1));
if (k.getItemDamage() >= k.getMaxDamage()) {
k.stackSize--;
}
event.craftMatrix.setInventorySlotContents(i, k);
event.player.worldObj.playSoundAtEntity(event.player, "mob.sheep.shear", 0.8F, 1.0F );
}
}
}
}
}

View File

@@ -0,0 +1,85 @@
package com.kitsu.medievalcraft.crafting;
import java.util.Hashtable;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import com.kitsu.medievalcraft.item.ModItems;
public class ForgeAnvilCrafting {
public static final Hashtable<Integer, Item> itemToCheck = new Hashtable <Integer, Item>(){{
put(0, ModItems.ironPickaxeForm);
put(1, ModItems.ironSpadForm);
put(2, ModItems.ironHoeForm);
put(3, ModItems.ironAxeForm);
put(4, ModItems.ironLongswordForm);
put(5, ModItems.ironShortSwordForm);
put(6, ModItems.ironDaggerForm);
put(7, ModItems.ironSpearTipForm);
put(8, ModItems.ironMaceHeadForm);
put(9, ModItems.ironBattleAxeForm);
put(10, ModItems.ironSawBladeForm);
put(11, ModItems.ironSharpTipForm);
put(12, ModItems.ironRingForm);
put(13, ModItems.ironHandleForm);
}};
public static final Hashtable<Integer, Item> itemToCheckClay = new Hashtable <Integer, Item>(){{
put(0, ModItems.cookedpickaxeClayForm);
put(1, ModItems.cookedspadeHeadClayForm);
put(2, ModItems.cookedhoeHeadClayForm);
put(3, ModItems.cookedaxeHeadClayForm);
put(4, ModItems.cookedlongswordClayForm);
put(5, ModItems.cookedshortswordClayForm);
put(6, ModItems.cookeddaggerClayForm);
put(7, ModItems.cookedspeartipClayForm);
put(8, ModItems.cookedmaceheadClayForm);
put(9, ModItems.cookedbattleaxeClayForm);
put(10, ModItems.cookedsawbladeClayForm);
put(11, ModItems.cookedsharptipClayForm);
put(12, ModItems.cookedringClayForm);
}};
public static final Hashtable<Integer, ItemStack> itemToGive = new Hashtable <Integer, ItemStack>(){{
put(0, new ItemStack (ModItems.ironpickaxeHead, 1, 0));
put(1, new ItemStack (ModItems.ironspadeHead, 1, 0));
put(2, new ItemStack (ModItems.ironhoeHead, 1, 0));
put(3, new ItemStack (ModItems.ironaxeHead, 1, 0));
put(4, new ItemStack (ModItems.ironlongswordBlade, 1, 0));
put(5, new ItemStack (ModItems.ironshortswordBlade,2,0));
put(6, new ItemStack (ModItems.irondaggerBlade, 3,0));
put(7, new ItemStack (ModItems.ironspearTip, 1, 0));
put(8, new ItemStack (ModItems.ironmaceHead, 1, 0));
put(9, new ItemStack (ModItems.ironbattleaxeHead, 1, 0));
put(10, new ItemStack (ModItems.ironsawBlade, 1, 0));
put(11, new ItemStack (ModItems.ironsharpTip,9,0));
put(12, new ItemStack (ModItems.ironRing,9,0));
put(13, new ItemStack (ModItems.ironweaponHandle, 2, 0));
}};
public static final Hashtable<Integer, String> toolToRepair = new Hashtable <Integer, String>(){{
put(0, "Forged Pickaxe");
put(1, "Forged Shovel");
put(2, "Forged Lumber Axe");
put(3, "Leather Shears");
put(4, "Iron Saw");
put(5, "Iron Shield");
put(6, "Heavy Mace");
put(7, "Longsword");
put(8, "Forge Hammer");
put(9, "Crafting Blade");
put(10, "Gladius");
}};
}

View File

@@ -0,0 +1,259 @@
package com.kitsu.medievalcraft.crafting;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import com.kitsu.medievalcraft.item.ModItems;
import cpw.mods.fml.common.registry.GameRegistry;
public class FormTableCraftManager implements IRecipe{
private static final FormTableCraftManager instance = new FormTableCraftManager();
private List recipes = new ArrayList();
private ItemStack output = null;
private Object[] input = null;
private int width = 0;
private int height = 0;
private boolean mirrored = true;
//private static final String __OBFID = "CL_00000090";
public static final FormTableCraftManager getInstance() {
return instance;
}
private FormTableCraftManager () {
recipes = new ArrayList();
////////RECIPES////////////////////////////////////////////////////////
//EXAMPLE RECIPE
//this.addRecipe(new ItemStack(ModItems.longSword, 1), new Object[]{"S", "S", "S", "S", "S", 'S', Items.stick});
//this.addRecipe(new ItemStack(ModItems.xxx, 1), new Object[]{"", "", "", "", "", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.pickaxeClayForm, 1), new Object[]{ "ccccc", "cc cc", "c c", " c ", "ccccc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.spadeHeadClayForm, 1), new Object[]{ "ccccc", "cc cc", "c c", "c c", "ccccc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.hoeHeadClayForm, 1), new Object[]{ "ccccc", "c c", "c ccc", "ccccc", "ccccc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.axeHeadClayForm, 1), new Object[]{ "ccccc", "c ccc", " c", "c ccc", "ccccc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.longswordClayForm, 1), new Object[]{ "cccc ", "ccc c", "cc cc", "c ccc", " cccc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.shortswordClayForm, 1), new Object[]{"cc cc", "cc cc", "cc cc", "c c", "cc cc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.daggerClayForm, 1), new Object[]{ "ccccc", "cc cc", "cc cc", "cc cc", "ccccc", 'c', Items.clay_ball});
//this.addRecipe(new ItemStack(ModItems.halberdClayForm, 1), new Object[]{ "ccccc", "c ccc", " ", " cc", "c ccc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.speartipClayForm, 1), new Object[]{ "ccccc", "cc cc", "cc cc", "c c", "ccccc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.maceheadClayForm, 1), new Object[]{ "cc cc", "c c", " ", "c c", "cc cc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.sharptipClayForm, 1), new Object[]{ "ccccc", "cc cc", "c c", "ccccc", "ccccc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.battleaxeClayForm, 1), new Object[]{ "c c c", " ", " ", " ", "c c c", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.ringClayForm, 1), new Object[]{ "ccccc", "cc cc", "c c", "cc cc", "ccccc", 'c', Items.clay_ball});
//this.addRecipe(new ItemStack(ModItems.plateClayForm, 1), new Object[]{ "ccccc", "c c", "c c", "c c", "ccccc", 'c', Items.clay_ball});
this.addRecipe(new ItemStack(ModItems.sawbladeClayForm, 1), new Object[]{ "ccccc", "ccccc", " ", "c ", "ccccc", 'c', Items.clay_ball});
Collections.sort(this.recipes, new FormTableRecipeSorter(this));
}
public FormTableShapedRecipes addRecipe(ItemStack p_92103_1_, Object ... p_92103_2_)
{
String s = "";
int i = 0;
int j = 0;
int k = 0;
if (p_92103_2_[i] instanceof String[])
{
@SuppressWarnings("cast")
String[] astring = (String[])((String[])p_92103_2_[i++]);
for (int l = 0; l < astring.length; ++l)
{
String s1 = astring[l];
++k;
j = s1.length();
s = s + s1;
}
}
else
{
while (p_92103_2_[i] instanceof String)
{
String s2 = (String)p_92103_2_[i++];
++k;
j = s2.length();
s = s + s2;
}
}
HashMap hashmap;
for (hashmap = new HashMap(); i < p_92103_2_.length; i += 2)
{
Character character = (Character)p_92103_2_[i];
ItemStack itemstack1 = null;
if (p_92103_2_[i + 1] instanceof Item)
{
itemstack1 = new ItemStack((Item)p_92103_2_[i + 1]);
}
else if (p_92103_2_[i + 1] instanceof Block)
{
itemstack1 = new ItemStack((Block)p_92103_2_[i + 1], 1, 32767);
}
else if (p_92103_2_[i + 1] instanceof ItemStack)
{
itemstack1 = (ItemStack)p_92103_2_[i + 1];
}
hashmap.put(character, itemstack1);
}
ItemStack[] aitemstack = new ItemStack[j * k];
for (int i1 = 0; i1 < j * k; ++i1)
{
char c0 = s.charAt(i1);
if (hashmap.containsKey(Character.valueOf(c0)))
{
aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c0))).copy();
}
else
{
aitemstack[i1] = null;
}
}
FormTableShapedRecipes shapedrecipes = new FormTableShapedRecipes(j, k, aitemstack, p_92103_1_);
this.recipes.add(shapedrecipes);
return shapedrecipes;
}
public void addShapelessRecipe(ItemStack p_77596_1_, Object ... p_77596_2_)
{
ArrayList arraylist = new ArrayList();
Object[] aobject = p_77596_2_;
int i = p_77596_2_.length;
for (int j = 0; j < i; ++j)
{
Object object1 = aobject[j];
if (object1 instanceof ItemStack)
{
arraylist.add(((ItemStack)object1).copy());
}
else if (object1 instanceof Item)
{
arraylist.add(new ItemStack((Item)object1));
}
else
{
if (!(object1 instanceof Block))
{
throw new RuntimeException("Invalid shapeless recipy!");
}
arraylist.add(new ItemStack((Block)object1));
}
}
this.recipes.add(new ShapelessRecipes(p_77596_1_, arraylist));
}
public ItemStack findMatchingRecipe(InventoryCrafting p_82787_1_, World p_82787_2_)
{
int i = 0;
ItemStack itemstack = null;
ItemStack itemstack1 = null;
int j;
for (j = 0; j < p_82787_1_.getSizeInventory(); ++j)
{
ItemStack itemstack2 = p_82787_1_.getStackInSlot(j);
if (itemstack2 != null)
{
if (i == 0)
{
itemstack = itemstack2;
}
if (i == 1)
{
itemstack1 = itemstack2;
}
++i;
}
}
if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && itemstack.getItem().isRepairable())
{
Item item = itemstack.getItem();
int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
int l = j1 + k + item.getMaxDamage() * 5 / 100;
int i1 = item.getMaxDamage() - l;
if (i1 < 0)
{
i1 = 0;
}
return new ItemStack(itemstack.getItem(), 1, i1);
}
for (j = 0; j < this.recipes.size(); ++j)
{
IRecipe irecipe = (IRecipe)this.recipes.get(j);
if (irecipe.matches(p_82787_1_, p_82787_2_))
{
return irecipe.getCraftingResult(p_82787_1_);
}
}
return null;
}
/**
* returns the List<> of all recipes
*/
public List getRecipeList()
{
return this.recipes;
}
@Override
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) {
// TODO Auto-generated method stub
return false;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting p_77572_1_) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getRecipeSize() {
// TODO Auto-generated method stub
return 0;
}
@Override
public ItemStack getRecipeOutput() {
// TODO Auto-generated method stub
return null;
}
}

View File

@@ -0,0 +1,24 @@
package com.kitsu.medievalcraft.crafting;
import java.util.Comparator;
import net.minecraft.item.crafting.IRecipe;
public class FormTableRecipeSorter implements Comparator {
final FormTableCraftManager formTable;
public FormTableRecipeSorter(FormTableCraftManager ftcraftmanage) {
this.formTable = ftcraftmanage;
}
public int compareRecipes(IRecipe irecipe1, IRecipe irecipe2) {
return irecipe1 instanceof FormTableShapelessRecipes && irecipe2 instanceof FormTableShapedRecipes ? 1 : (irecipe2 instanceof FormTableShapelessRecipes && irecipe1 instanceof FormTableShapedRecipes ? -1 : (irecipe2.getRecipeSize() > irecipe1.getRecipeSize() ? -1 : (irecipe2.getRecipeSize() > irecipe1.getRecipeSize() ? 1 : 0)));
}
@Override
public int compare(Object o1, Object o2) {
return this.compareRecipes((IRecipe)o1, (IRecipe)o2);
}
}

View File

@@ -0,0 +1,145 @@
package com.kitsu.medievalcraft.crafting;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class FormTableShapedRecipes implements IRecipe
{
/** How many horizontal slots this recipe is wide. */
public final int recipeWidth;
/** How many vertical slots this recipe uses. */
public final int recipeHeight;
/** Is a array of ItemStack that composes the recipe. */
public final ItemStack[] recipeItems;
/** Is the ItemStack that you get when craft the recipe. */
private ItemStack recipeOutput;
private boolean field_92101_f;
//private static final String __OBFID = "CL_00000093";
public FormTableShapedRecipes(int p_i1917_1_, int p_i1917_2_, ItemStack[] p_i1917_3_, ItemStack p_i1917_4_)
{
this.recipeWidth = p_i1917_1_;
this.recipeHeight = p_i1917_2_;
this.recipeItems = p_i1917_3_;
this.recipeOutput = p_i1917_4_;
}
public ItemStack getRecipeOutput()
{
return this.recipeOutput;
}
/**
* Used to check if a recipe matches current crafting inventory
*/
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_)
{
for (int i = 0; i <= 5 - this.recipeWidth; ++i)
{
for (int j = 0; j <= 5 - this.recipeHeight; ++j)
{
if (this.checkMatch(p_77569_1_, i, j, true))
{
return true;
}
if (this.checkMatch(p_77569_1_, i, j, false))
{
return true;
}
}
}
return false;
}
/**
* Checks if the region of a crafting inventory is match for the recipe.
*/
private boolean checkMatch(InventoryCrafting p_77573_1_, int p_77573_2_, int p_77573_3_, boolean p_77573_4_)
{
for (int k = 0; k < 5; ++k)
{
for (int l = 0; l < 5; ++l)
{
int i1 = k - p_77573_2_;
int j1 = l - p_77573_3_;
ItemStack itemstack = null;
if (i1 >= 0 && j1 >= 0 && i1 < this.recipeWidth && j1 < this.recipeHeight)
{
if (p_77573_4_)
{
itemstack = this.recipeItems[this.recipeWidth - i1 - 1 + j1 * this.recipeWidth];
}
else
{
itemstack = this.recipeItems[i1 + j1 * this.recipeWidth];
}
}
ItemStack itemstack1 = p_77573_1_.getStackInRowAndColumn(k, l);
if (itemstack1 != null || itemstack != null)
{
if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null)
{
return false;
}
if (itemstack.getItem() != itemstack1.getItem())
{
return false;
}
if (itemstack.getItemDamage() != 32767 && itemstack.getItemDamage() != itemstack1.getItemDamage())
{
return false;
}
}
}
}
return true;
}
/**
* Returns an Item that is the result of this recipe
*/
public ItemStack getCraftingResult(InventoryCrafting p_77572_1_)
{
ItemStack itemstack = this.getRecipeOutput().copy();
if (this.field_92101_f)
{
for (int i = 0; i < p_77572_1_.getSizeInventory(); ++i)
{
ItemStack itemstack1 = p_77572_1_.getStackInSlot(i);
if (itemstack1 != null && itemstack1.hasTagCompound())
{
itemstack.setTagCompound((NBTTagCompound)itemstack1.stackTagCompound.copy());
}
}
}
return itemstack;
}
/**
* Returns the size of the recipe area
*/
public int getRecipeSize()
{
return this.recipeWidth * this.recipeHeight;
}
public FormTableShapedRecipes func_92100_c()
{
this.field_92101_f = true;
return this;
}
}

View File

@@ -0,0 +1,87 @@
package com.kitsu.medievalcraft.crafting;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
public class FormTableShapelessRecipes implements IRecipe{
/** Is the ItemStack that you get when craft the recipe. */
private final ItemStack recipeOutput;
/** Is a List of ItemStack that composes the recipe. */
public final List recipeItems;
//private static final String __OBFID = "CL_00000094";
public FormTableShapelessRecipes(ItemStack p_i1918_1_, List p_i1918_2_)
{
this.recipeOutput = p_i1918_1_;
this.recipeItems = p_i1918_2_;
}
public ItemStack getRecipeOutput()
{
return this.recipeOutput;
}
/**
* Used to check if a recipe matches current crafting inventory
*/
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_)
{
ArrayList arraylist = new ArrayList(this.recipeItems);
for (int i = 0; i < 5; ++i)
{
for (int j = 0; j < 5; ++j)
{
ItemStack itemstack = p_77569_1_.getStackInRowAndColumn(j, i);
if (itemstack != null)
{
boolean flag = false;
Iterator iterator = arraylist.iterator();
while (iterator.hasNext())
{
ItemStack itemstack1 = (ItemStack)iterator.next();
if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getItemDamage() == 32767 || itemstack.getItemDamage() == itemstack1.getItemDamage()))
{
flag = true;
arraylist.remove(itemstack1);
break;
}
}
if (!flag)
{
return false;
}
}
}
}
return arraylist.isEmpty();
}
/**
* Returns an Item that is the result of this recipe
*/
public ItemStack getCraftingResult(InventoryCrafting p_77572_1_)
{
return this.recipeOutput.copy();
}
/**
* Returns the size of the recipe area
*/
public int getRecipeSize()
{
return this.recipeItems.size();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,61 @@
package com.kitsu.medievalcraft.crafting;
import java.util.Hashtable;
import net.minecraft.block.Block;
import com.kitsu.medievalcraft.block.ModBlocks;
public class TestForgeCrafting {
public static final Hashtable<Integer, Block> blockToCheck = new Hashtable <Integer, Block>(){{
/*put(0, ModBlocks.myIronIngot);
put(1, ModBlocks.filledCrucibleIron);
put(2, ModBlocks.emptySoftCrucible);
put(3, ModBlocks.ironPlate);
put(4, ModBlocks.filledCrucibleIronIngot);
put(5, ModBlocks.filledCrucibleDamascus);
put(6, ModBlocks.damascusIngot);
put(7, ModBlocks.filledLapisCrucible);
put(8, ModBlocks.lapisIngot);
put(9, ModBlocks.redstoneIngot);
put(10, ModBlocks.filledRedstoneCrucible);*/
}};
/*public static final Hashtable<Integer, Integer> cookTable= new Hashtable <Integer, Integer>(){{
put(0, 300);
put(1, 1000);
put(2, 200);
put(3, 250);
put(4, 750);
put(5, 1200);
put(6, 400);
put(7, 900);
put(8, 400);
put(9, 400);
put(10, 900);
}};*/
public static final Hashtable<Integer, Block> blockToCook = new Hashtable <Integer, Block>(){{
put(0, ModBlocks.refinedIron);
//put(1, ModBlocks.crucibleIronOre);
//put(2, ModBlocks.emptyCookedCrucible);
put(3, ModBlocks.ironPlate);
//put(4, ModBlocks.hotCrucibleIron);
//put(5, ModBlocks.hotCrucibleDamascus);
put(6, ModBlocks.damascus);
//put(7, ModBlocks.hotLapisCrucible);
//put(8, ModBlocks.hotLapisIngot);
//put(9, ModBlocks.hotRedstoneIngot);
//put(10, ModBlocks.hotRedstoneCrucible);
}};
}

View File

@@ -0,0 +1,152 @@
package com.kitsu.medievalcraft.entity;
import java.util.List;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.util.CannonUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityCannonBall extends Entity implements CannonUtil{
private EntityLivingBase tntPlacedBy;
public int damage = 100;
private int field_145791_d = -1;
private int field_145792_e = -1;
private int field_145789_f = -1;
private int h;
public Entity shootingEntity;
private boolean smoke = true;
public EntityCannonBall(World p_i1582_1_) {
super(p_i1582_1_);
this.preventEntitySpawning = true;
this.setSize(0.5F, 0.5F);
//this.yOffset = this.height / 2.0F;
this.boundingBox.setBounds(0.49, 0.49, 0.49, 0.51, 0.51, 0.51);
}
public EntityCannonBall(World world, double x, double y, double z, EntityLivingBase entLiving)
{
this(world);
this.setPosition(x, y, z);
float f = (float)(Math.random() * Math.PI * 2.0D);
this.motionX = (double)(-((float)Math.sin((double)f)) * 0.02F);
this.motionY = 0.05D;
this.motionZ = (double)(-((float)Math.cos((double)f)) * 0.02F);
this.prevPosX = x;
this.prevPosY = y;
this.prevPosZ = z;
this.tntPlacedBy = entLiving;
this.renderDistanceWeight = 100;
this.smoke = true;
}
public void onUpdate()
{
if(h > 0 && h < 2){
if(this.smoke==true){
for(int g = 0; g < 50; g++){
this.worldObj.spawnParticle("explode", this.posX + (worldObj.rand.nextFloat()*2 - 1), this.posY + (worldObj.rand.nextFloat()*2 - 1), (this.posZ + worldObj.rand.nextFloat()*2 - 1),0.0, 0.0, 0.0);
}
this.smoke=false;
}
}
h++;
/*double x = this.posX;
double y = this.posY;
double z = this.posZ;
if(worldObj.isRemote){
if(this.smoke==true){
for(int g = 0; g < 10; g++){
worldObj.spawnParticle("largesmoke", x +worldObj.rand.nextFloat()/10, y+worldObj.rand.nextFloat()/10, z +worldObj.rand.nextFloat()/10,
1.0, 1.0D, 1.0);
}
this.smoke=false;
}
}*/
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionY -= 0.03999999910593033D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition mop = this.worldObj.func_147447_a(vec31, vec3, false, true, false);
vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (mop != null)
{
vec3 = Vec3.createVectorHelper(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
//System.out.println(mop.entityHit);
}
if(!worldObj.isRemote){
if(this.motionX==0||this.motionY==0||this.motionZ==0){
this.explode();
this.setDead();
}
}
}
@Override
public boolean canBeCollidedWith()
{
return true;
}
private void explode()
{
float f = 1F+(this.worldObj.rand.nextFloat()/3)+(this.worldObj.rand.nextFloat()/4)+this.worldObj.rand.nextFloat()/5;
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true);
}
@Override
protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {
}
@Override
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {
}
public EntityLivingBase getTntPlacedBy()
{
return this.tntPlacedBy;
}
@Override
protected void entityInit() {
this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
}
}

View File

@@ -0,0 +1,597 @@
package com.kitsu.medievalcraft.entity;
import java.util.List;
import com.kitsu.medievalcraft.item.ModItems;
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.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityITSpear extends EntityArrow implements IProjectile {
private int field_145791_d = -1;
private int field_145792_e = -1;
private int field_145789_f = -1;
private Block field_145790_g;
private int inData;
private boolean inGround;
/** 1 if the player can pick up the arrow */
public int canBePickedUp;
/** Seems to be some sort of timer for animating an arrow. */
public int arrowShake;
/** The owner of this arrow. */
public Entity shootingEntity;
private int ticksInGround;
private int ticksInAir;
private double damage = 35.0D;
/** The amount of knockback an arrow applies when it hits a mob. */
private int knockbackStrength;
public EntityITSpear(World world)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.setSize(0.5F, 0.5F);
}
public EntityITSpear(World world, double x, double y, double z)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.setSize(0.5F, 0.5F);
this.setPosition(x, y, z);
this.yOffset = 0.0F;
}
@SuppressWarnings("cast")
public EntityITSpear(World world, EntityLivingBase player, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = player;
if (player instanceof EntityPlayer)
{
this.canBePickedUp = 1;
}
this.posY = player.posY + (double)player.getEyeHeight() + 0.10000000149011612D;
double d0 = p_i1755_3_.posX - player.posX;
double d1 = p_i1755_3_.boundingBox.minY + (double)(p_i1755_3_.height / 3.0F) - this.posY;
double d2 = p_i1755_3_.posZ - player.posZ;
double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
if (d3 >= 1.0E-7D)
{
float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
double d4 = d0 / d3;
double d5 = d2 / d3;
this.setLocationAndAngles(player.posX + d4, this.posY, player.posZ + d5, f2, f3);
this.yOffset = 0.0F;
float f4 = (float)d3 * 0.2F;
this.setThrowableHeading(d0, d1 + (double)f4, d2, p_i1755_4_, p_i1755_5_);
}
}
@SuppressWarnings("cast")
public EntityITSpear(World world, EntityLivingBase player, float p_i1756_3_)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = player;
if (player instanceof EntityPlayer)
{
this.canBePickedUp = 1;
}
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, player.rotationPitch);
this.posX += (player.getLookVec().xCoord);
//this.posY -= 0.10000000149011612D;
this.posZ += (player.getLookVec().zCoord);
//this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.posY += player.getLookVec().yCoord;
if(player.getLookVec().yCoord < 0){
this.posY += player.getLookVec().yCoord * 2;
}
this.setPosition(this.posX, this.posY, this.posZ);
//this.setSize(0.5F, 0.5F);
//this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, player.rotationPitch);
//this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
//this.posY -= 0.10000000149011612D;
//this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
//this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F);
}
protected void entityInit()
{
this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
*/
@SuppressWarnings("cast")
public void setThrowableHeading(double x, double y, double z, float p_70186_7_, float p_70186_8_)
{
float f2 = MathHelper.sqrt_double(x * x + y * y + z * z);
x /= (double)f2;
y /= (double)f2;
z /= (double)f2;
x += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
y += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
z += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
x *= (double)p_70186_7_;
y *= (double)p_70186_7_;
z *= (double)p_70186_7_;
this.motionX = x/2.5;
this.motionY = y/1.75;
this.motionZ = z/2.5;
float f3 = MathHelper.sqrt_double(x * x + z * z);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI);
this.ticksInGround = 1;
}
/**
* Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
* posY, posZ, yaw, pitch
*/
@SideOnly(Side.CLIENT)
public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_)
{
this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_);
this.setRotation(p_70056_7_, p_70056_8_);
}
/**
* Sets the velocity to the args. Args: x, y, z
*/
@SuppressWarnings("cast")
@SideOnly(Side.CLIENT)
public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_)
{
this.motionX = p_70016_1_ ;
this.motionY = p_70016_3_ ;
this.motionZ = p_70016_5_ ;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch;
this.prevRotationYaw = this.rotationYaw;
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
this.ticksInGround = 0;
}
}
/**
* Called to update the entity's position/logic.
*/
@SuppressWarnings("cast")
public void onUpdate()
{
super.onUpdate();
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI);
}
Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
//this.getEntityData().setInteger("blockX", this.field_145791_d);
if (block.getMaterial() != Material.air)
{
block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
{
this.inGround = true;
}
}
if (this.arrowShake > 0)
{
--this.arrowShake;
}
if (this.inGround)
{
int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (block == this.field_145790_g && j == this.inData)
{
++this.ticksInGround;
if (this.ticksInGround == -1)
{
//this.setDead();
}
}
else
{
this.inGround = false;
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
this.ticksInGround = 0;
this.ticksInAir = 0;
}
}
else
{
++this.ticksInAir;
Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false);
vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int i;
float f1;
for (i = 0; i < list.size(); ++i)
{
Entity entity1 = (Entity)list.get(i);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
{
f1 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
if (movingobjectposition1 != null)
{
double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
this.inGround=true;
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))
{
movingobjectposition = null;
}
}
float f2;
float f4;
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
int k = MathHelper.ceiling_double_int((double)f2 * this.damage);
DamageSource damagesource = null;
if (this.shootingEntity == null)
{
//EntityPlayer player = (EntityPlayer) movingobjectposition.entityHit;
//System.out.println(player.inventory.getTotalArmorValue());
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
//damagesource = DamageSource.
}
else
{
damagesource = DamageSource.causeThrownDamage(this, this.shootingEntity);
}
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
{
movingobjectposition.entityHit.setFire(5);
}
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k))
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit;
if (!this.worldObj.isRemote)
{
//entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1);
}
if (this.knockbackStrength > 0)
{
f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f4 > 0.0F)
{
movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4);
}
}
if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase)
{
EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity);
EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase);
}
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
{
((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
}
}
//this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
if (!(movingobjectposition.entityHit instanceof EntityEnderman))
{
this.inGround = true;
}
}
else
{
this.motionX *= -0.10000000149011612D;
this.motionY *= -0.10000000149011612D;
this.motionZ *= -0.10000000149011612D;
this.rotationYaw += 180.0F;
this.prevRotationYaw += 180.0F;
this.ticksInAir = 0;
}
this.inGround=true;
}
else
{
this.field_145791_d = movingobjectposition.blockX;
this.field_145792_e = movingobjectposition.blockY;
this.field_145789_f = movingobjectposition.blockZ;
this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX));
this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY));
this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ));
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / (double)f2 * 0.05000000074505806D;
this.posY -= this.motionY / (double)f2 * 0.05000000074505806D;
this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D;
//this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
this.inGround = true;
this.arrowShake = 7;
if (this.field_145790_g.getMaterial() != Material.air)
{
this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
}
}
this.inGround=true;
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f3 = 0.99F;
f1 = 0.05F;
if (this.isInWater())
{
for (int l = 0; l < 4; ++l)
{
f4 = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
}
f3 = 0.8F;
}
if (this.isWet())
{
this.extinguish();
}
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
this.inGround=true;
}
}
this.motionX *= (double)f3;
this.motionY *= (double)f3;
this.motionZ *= (double)f3;
this.motionY -= (double)f1;
this.setPosition(this.posX, this.posY, this.posZ);
this.func_145775_I();
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound p_70014_1_)
{
p_70014_1_.setShort("xTile", (short)this.field_145791_d);
p_70014_1_.setShort("yTile", (short)this.field_145792_e);
p_70014_1_.setShort("zTile", (short)this.field_145789_f);
p_70014_1_.setShort("life", (short)this.ticksInGround);
p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g));
p_70014_1_.setByte("inData", (byte)this.inData);
p_70014_1_.setByte("shake", (byte)this.arrowShake);
p_70014_1_.setByte("inGround", (byte)(this.inGround ? 1 : 0));
p_70014_1_.setByte("pickup", (byte)this.canBePickedUp);
p_70014_1_.setDouble("damage", this.damage);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound p_70037_1_)
{
this.field_145791_d = p_70037_1_.getShort("xTile");
this.field_145792_e = p_70037_1_.getShort("yTile");
this.field_145789_f = p_70037_1_.getShort("zTile");
this.ticksInGround = p_70037_1_.getShort("life");
this.field_145790_g = Block.getBlockById(p_70037_1_.getByte("inTile") & 255);
this.inData = p_70037_1_.getByte("inData") & 255;
this.arrowShake = p_70037_1_.getByte("shake") & 255;
this.inGround = p_70037_1_.getByte("inGround") == 1;
if (p_70037_1_.hasKey("damage", 99))
{
this.damage = p_70037_1_.getDouble("damage");
}
if (p_70037_1_.hasKey("pickup", 99))
{
this.canBePickedUp = p_70037_1_.getByte("pickup");
}
else if (p_70037_1_.hasKey("player", 99))
{
this.canBePickedUp = p_70037_1_.getBoolean("player") ? 1 : 0;
}
}
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer p_70100_1_)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && p_70100_1_.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !p_70100_1_.inventory.addItemStackToInventory(new ItemStack(ModItems.itemITSpear, 1)))
{
flag = false;
}
if (flag)
{
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
p_70100_1_.onItemPickup(this, 1);
this.setDead();
}
}
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
* prevent them from trampling crops
*/
protected boolean canTriggerWalking()
{
return false;
}
@SideOnly(Side.CLIENT)
public float getShadowSize()
{
return 2.0F;
}
public void setDamage(double p_70239_1_)
{
this.damage = p_70239_1_;
}
public double getDamage()
{
return this.damage;
}
/**
* Sets the amount of knockback the arrow applies when it hits a mob.
*/
public void setKnockbackStrength(int p_70240_1_)
{
this.knockbackStrength = p_70240_1_;
}
/**
* If returns false, the item will not inflict any damage against entities.
*/
public boolean canAttackWithItem()
{
return true;
}
}

View File

@@ -0,0 +1,582 @@
package com.kitsu.medievalcraft.entity;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.item.ModItems;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class EntityModelArrow extends EntityArrow implements IProjectile {
private int field_145791_d = -1;
private int field_145792_e = -1;
private int field_145789_f = -1;
private Block field_145790_g;
private int inData;
private boolean inGround;
/** 1 if the player can pick up the arrow */
public int canBePickedUp;
/** Seems to be some sort of timer for animating an arrow. */
public int arrowShake;
/** The owner of this arrow. */
public Entity shootingEntity;
private int ticksInGround;
private int ticksInAir;
private double damage = 4.0D;
/** The amount of knockback an arrow applies when it hits a mob. */
private int knockbackStrength;
public EntityModelArrow(World world)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.setSize(0.5F, 0.5F);
}
public EntityModelArrow(World world, double x, double y, double z)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.setSize(0.5F, 0.5F);
this.setPosition(x, y, z);
this.yOffset = 0.0F;
}
@SuppressWarnings("cast")
public EntityModelArrow(World world, EntityLivingBase player, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = player;
if (player instanceof EntityPlayer)
{
this.canBePickedUp = 1;
}
this.posY = player.posY + (double)player.getEyeHeight() + 0.10000000149011612D;
double d0 = p_i1755_3_.posX - player.posX;
double d1 = p_i1755_3_.boundingBox.minY + (double)(p_i1755_3_.height / 3.0F) - this.posY;
double d2 = p_i1755_3_.posZ - player.posZ;
double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
if (d3 >= 1.0E-7D)
{
float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
double d4 = d0 / d3;
double d5 = d2 / d3;
this.setLocationAndAngles(player.posX + d4, this.posY, player.posZ + d5, f2, f3);
this.yOffset = 0.0F;
float f4 = (float)d3 * 0.2F;
this.setThrowableHeading(d0, d1 + (double)f4, d2, p_i1755_4_, p_i1755_5_);
}
}
@SuppressWarnings("cast")
public EntityModelArrow(World world, EntityLivingBase player, float p_i1756_3_)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = player;
if (player instanceof EntityPlayer)
{
this.canBePickedUp = 1;
}
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, player.rotationPitch);
this.posX += (player.getLookVec().xCoord);
//this.posY -= 0.10000000149011612D;
this.posZ += (player.getLookVec().zCoord);
//this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.posY += player.getLookVec().yCoord;
if(player.getLookVec().yCoord < 0){
this.posY += player.getLookVec().yCoord * 2;
}
this.setPosition(this.posX, this.posY, this.posZ);
//this.setSize(0.5F, 0.5F);
//this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, player.rotationPitch);
//this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
//this.posY -= 0.10000000149011612D;
//this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
//this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F);
}
protected void entityInit()
{
this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
*/
@SuppressWarnings("cast")
public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_)
{
float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_);
p_70186_1_ /= (double)f2;
p_70186_3_ /= (double)f2;
p_70186_5_ /= (double)f2;
p_70186_1_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
p_70186_3_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
p_70186_5_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
p_70186_1_ *= (double)p_70186_7_;
p_70186_3_ *= (double)p_70186_7_;
p_70186_5_ *= (double)p_70186_7_;
this.motionX = p_70186_1_;
this.motionY = p_70186_3_;
this.motionZ = p_70186_5_;
float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70186_3_, (double)f3) * 180.0D / Math.PI);
this.ticksInGround = 1;
}
/**
* Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
* posY, posZ, yaw, pitch
*/
@SideOnly(Side.CLIENT)
public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_)
{
this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_);
this.setRotation(p_70056_7_, p_70056_8_);
}
/**
* Sets the velocity to the args. Args: x, y, z
*/
@SuppressWarnings("cast")
@SideOnly(Side.CLIENT)
public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_)
{
this.motionX = p_70016_1_ ;
this.motionY = p_70016_3_ ;
this.motionZ = p_70016_5_ ;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch;
this.prevRotationYaw = this.rotationYaw;
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
this.ticksInGround = 0;
}
}
/**
* Called to update the entity's position/logic.
*/
@SuppressWarnings("cast")
public void onUpdate()
{
super.onUpdate();
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI);
}
Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
//this.getEntityData().setInteger("blockX", this.field_145791_d);
if (block.getMaterial() != Material.air)
{
block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
{
this.inGround = true;
}
}
if (this.arrowShake > 0)
{
--this.arrowShake;
}
if (this.inGround)
{
int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (block == this.field_145790_g && j == this.inData)
{
++this.ticksInGround;
if (this.ticksInGround == -1)
{
this.setDead();
}
}
else
{
this.inGround = false;
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
this.ticksInGround = 0;
this.ticksInAir = 0;
}
}
else
{
++this.ticksInAir;
Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false);
vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int i;
float f1;
for (i = 0; i < list.size(); ++i)
{
Entity entity1 = (Entity)list.get(i);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
{
f1 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
if (movingobjectposition1 != null)
{
double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))
{
movingobjectposition = null;
}
}
float f2;
float f4;
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
int k = MathHelper.ceiling_double_int((double)f2 * this.damage);
DamageSource damagesource = null;
if (this.shootingEntity == null)
{
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
}
else
{
damagesource = DamageSource.causeThrownDamage(this, this.shootingEntity);
}
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
{
movingobjectposition.entityHit.setFire(5);
}
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k))
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit;
if (!this.worldObj.isRemote)
{
entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1);
}
if (this.knockbackStrength > 0)
{
f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f4 > 0.0F)
{
movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4);
}
}
if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase)
{
EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity);
EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase);
}
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
{
((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
}
}
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
if (!(movingobjectposition.entityHit instanceof EntityEnderman))
{
this.setDead();
}
}
else
{
this.motionX *= -0.10000000149011612D;
this.motionY *= -0.10000000149011612D;
this.motionZ *= -0.10000000149011612D;
this.rotationYaw += 180.0F;
this.prevRotationYaw += 180.0F;
this.ticksInAir = 0;
}
}
else
{
this.field_145791_d = movingobjectposition.blockX;
this.field_145792_e = movingobjectposition.blockY;
this.field_145789_f = movingobjectposition.blockZ;
this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX));
this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY));
this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ));
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / (double)f2 * 0.05000000074505806D;
this.posY -= this.motionY / (double)f2 * 0.05000000074505806D;
this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D;
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
this.inGround = true;
this.arrowShake = 7;
if (this.field_145790_g.getMaterial() != Material.air)
{
this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
}
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f3 = 0.99F;
f1 = 0.05F;
if (this.isInWater())
{
for (int l = 0; l < 4; ++l)
{
f4 = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
}
f3 = 0.8F;
}
if (this.isWet())
{
this.extinguish();
}
this.motionX *= (double)f3;
this.motionY *= (double)f3;
this.motionZ *= (double)f3;
this.motionY -= (double)f1;
this.setPosition(this.posX, this.posY, this.posZ);
this.func_145775_I();
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound p_70014_1_)
{
p_70014_1_.setShort("xTile", (short)this.field_145791_d);
p_70014_1_.setShort("yTile", (short)this.field_145792_e);
p_70014_1_.setShort("zTile", (short)this.field_145789_f);
p_70014_1_.setShort("life", (short)this.ticksInGround);
p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g));
p_70014_1_.setByte("inData", (byte)this.inData);
p_70014_1_.setByte("shake", (byte)this.arrowShake);
p_70014_1_.setByte("inGround", (byte)(this.inGround ? 1 : 0));
p_70014_1_.setByte("pickup", (byte)this.canBePickedUp);
p_70014_1_.setDouble("damage", this.damage);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound p_70037_1_)
{
this.field_145791_d = p_70037_1_.getShort("xTile");
this.field_145792_e = p_70037_1_.getShort("yTile");
this.field_145789_f = p_70037_1_.getShort("zTile");
this.ticksInGround = p_70037_1_.getShort("life");
this.field_145790_g = Block.getBlockById(p_70037_1_.getByte("inTile") & 255);
this.inData = p_70037_1_.getByte("inData") & 255;
this.arrowShake = p_70037_1_.getByte("shake") & 255;
this.inGround = p_70037_1_.getByte("inGround") == 1;
if (p_70037_1_.hasKey("damage", 99))
{
this.damage = p_70037_1_.getDouble("damage");
}
if (p_70037_1_.hasKey("pickup", 99))
{
this.canBePickedUp = p_70037_1_.getByte("pickup");
}
else if (p_70037_1_.hasKey("player", 99))
{
this.canBePickedUp = p_70037_1_.getBoolean("player") ? 1 : 0;
}
}
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer p_70100_1_)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && p_70100_1_.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !p_70100_1_.inventory.addItemStackToInventory(new ItemStack(ModItems.itemModelArrow, 1)))
{
flag = false;
}
if (flag)
{
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
p_70100_1_.onItemPickup(this, 1);
this.setDead();
}
}
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
* prevent them from trampling crops
*/
protected boolean canTriggerWalking()
{
return false;
}
@SideOnly(Side.CLIENT)
public float getShadowSize()
{
return 0.0F;
}
public void setDamage(double p_70239_1_)
{
this.damage = p_70239_1_;
}
public double getDamage()
{
return this.damage;
}
/**
* Sets the amount of knockback the arrow applies when it hits a mob.
*/
public void setKnockbackStrength(int p_70240_1_)
{
this.knockbackStrength = p_70240_1_;
}
/**
* If returns false, the item will not inflict any damage against entities.
*/
public boolean canAttackWithItem()
{
return false;
}
}

View File

@@ -0,0 +1,581 @@
package com.kitsu.medievalcraft.entity;
import java.util.List;
import com.kitsu.medievalcraft.item.ModItems;
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.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityModelITArrow extends EntityArrow implements IProjectile {
private int field_145791_d = -1;
private int field_145792_e = -1;
private int field_145789_f = -1;
private Block field_145790_g;
private int inData;
private boolean inGround;
/** 1 if the player can pick up the arrow */
public int canBePickedUp;
/** Seems to be some sort of timer for animating an arrow. */
public int arrowShake;
/** The owner of this arrow. */
public Entity shootingEntity;
private int ticksInGround;
private int ticksInAir;
private double damage = 8.0D;
/** The amount of knockback an arrow applies when it hits a mob. */
private int knockbackStrength;
public EntityModelITArrow(World world)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.setSize(0.5F, 0.5F);
}
public EntityModelITArrow(World world, double x, double y, double z)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.setSize(0.5F, 0.5F);
this.setPosition(x, y, z);
this.yOffset = 0.0F;
}
@SuppressWarnings("cast")
public EntityModelITArrow(World world, EntityLivingBase player, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = player;
if (player instanceof EntityPlayer)
{
this.canBePickedUp = 1;
}
this.posY = player.posY + (double)player.getEyeHeight() + 0.10000000149011612D;
double d0 = p_i1755_3_.posX - player.posX;
double d1 = p_i1755_3_.boundingBox.minY + (double)(p_i1755_3_.height / 3.0F) - this.posY;
double d2 = p_i1755_3_.posZ - player.posZ;
double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
if (d3 >= 1.0E-7D)
{
float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
double d4 = d0 / d3;
double d5 = d2 / d3;
this.setLocationAndAngles(player.posX + d4, this.posY, player.posZ + d5, f2, f3);
this.yOffset = 0.0F;
float f4 = (float)d3 * 0.2F;
this.setThrowableHeading(d0, d1 + (double)f4, d2, p_i1755_4_, p_i1755_5_);
}
}
@SuppressWarnings("cast")
public EntityModelITArrow(World world, EntityLivingBase player, float p_i1756_3_)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = player;
if (player instanceof EntityPlayer)
{
this.canBePickedUp = 1;
}
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, player.rotationPitch);
this.posX += (player.getLookVec().xCoord);
//this.posY -= 0.10000000149011612D;
this.posZ += (player.getLookVec().zCoord);
//this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.posY += player.getLookVec().yCoord;
if(player.getLookVec().yCoord < 0){
this.posY += player.getLookVec().yCoord * 2;
}
this.setPosition(this.posX, this.posY, this.posZ);
//this.setSize(0.5F, 0.5F);
//this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, player.rotationPitch);
//this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
//this.posY -= 0.10000000149011612D;
//this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
//this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F);
}
protected void entityInit()
{
this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
*/
@SuppressWarnings("cast")
public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_)
{
float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_);
p_70186_1_ /= (double)f2;
p_70186_3_ /= (double)f2;
p_70186_5_ /= (double)f2;
p_70186_1_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
p_70186_3_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
p_70186_5_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
p_70186_1_ *= (double)p_70186_7_;
p_70186_3_ *= (double)p_70186_7_;
p_70186_5_ *= (double)p_70186_7_;
this.motionX = p_70186_1_;
this.motionY = p_70186_3_;
this.motionZ = p_70186_5_;
float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70186_3_, (double)f3) * 180.0D / Math.PI);
this.ticksInGround = 1;
}
/**
* Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
* posY, posZ, yaw, pitch
*/
@SideOnly(Side.CLIENT)
public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_)
{
this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_);
this.setRotation(p_70056_7_, p_70056_8_);
}
/**
* Sets the velocity to the args. Args: x, y, z
*/
@SuppressWarnings("cast")
@SideOnly(Side.CLIENT)
public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_)
{
this.motionX = p_70016_1_ ;
this.motionY = p_70016_3_ ;
this.motionZ = p_70016_5_ ;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch;
this.prevRotationYaw = this.rotationYaw;
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
this.ticksInGround = 0;
}
}
/**
* Called to update the entity's position/logic.
*/
@SuppressWarnings("cast")
public void onUpdate()
{
super.onUpdate();
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI);
}
Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
//this.getEntityData().setInteger("blockX", this.field_145791_d);
if (block.getMaterial() != Material.air)
{
block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
{
this.inGround = true;
}
}
if (this.arrowShake > 0)
{
--this.arrowShake;
}
if (this.inGround)
{
int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (block == this.field_145790_g && j == this.inData)
{
++this.ticksInGround;
if (this.ticksInGround == -1)
{
this.setDead();
}
}
else
{
this.inGround = false;
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
this.ticksInGround = 0;
this.ticksInAir = 0;
}
}
else
{
++this.ticksInAir;
Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false);
vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int i;
float f1;
for (i = 0; i < list.size(); ++i)
{
Entity entity1 = (Entity)list.get(i);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
{
f1 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
if (movingobjectposition1 != null)
{
double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))
{
movingobjectposition = null;
}
}
float f2;
float f4;
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
int k = MathHelper.ceiling_double_int((double)f2 * this.damage);
DamageSource damagesource = null;
if (this.shootingEntity == null)
{
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
}
else
{
damagesource = DamageSource.causeThrownDamage(this, this.shootingEntity);
}
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
{
movingobjectposition.entityHit.setFire(5);
}
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k))
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit;
if (!this.worldObj.isRemote)
{
entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1);
}
if (this.knockbackStrength > 0)
{
f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f4 > 0.0F)
{
movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4);
}
}
if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase)
{
EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity);
EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase);
}
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
{
((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
}
}
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
if (!(movingobjectposition.entityHit instanceof EntityEnderman))
{
this.setDead();
}
}
else
{
this.motionX *= -0.10000000149011612D;
this.motionY *= -0.10000000149011612D;
this.motionZ *= -0.10000000149011612D;
this.rotationYaw += 180.0F;
this.prevRotationYaw += 180.0F;
this.ticksInAir = 0;
}
}
else
{
this.field_145791_d = movingobjectposition.blockX;
this.field_145792_e = movingobjectposition.blockY;
this.field_145789_f = movingobjectposition.blockZ;
this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX));
this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY));
this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ));
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / (double)f2 * 0.05000000074505806D;
this.posY -= this.motionY / (double)f2 * 0.05000000074505806D;
this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D;
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
this.inGround = true;
this.arrowShake = 7;
if (this.field_145790_g.getMaterial() != Material.air)
{
this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
}
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f3 = 0.99F;
f1 = 0.05F;
if (this.isInWater())
{
for (int l = 0; l < 4; ++l)
{
f4 = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
}
f3 = 0.8F;
}
if (this.isWet())
{
this.extinguish();
}
this.motionX *= (double)f3;
this.motionY *= (double)f3;
this.motionZ *= (double)f3;
this.motionY -= (double)f1;
this.setPosition(this.posX, this.posY, this.posZ);
this.func_145775_I();
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound p_70014_1_)
{
p_70014_1_.setShort("xTile", (short)this.field_145791_d);
p_70014_1_.setShort("yTile", (short)this.field_145792_e);
p_70014_1_.setShort("zTile", (short)this.field_145789_f);
p_70014_1_.setShort("life", (short)this.ticksInGround);
p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g));
p_70014_1_.setByte("inData", (byte)this.inData);
p_70014_1_.setByte("shake", (byte)this.arrowShake);
p_70014_1_.setByte("inGround", (byte)(this.inGround ? 1 : 0));
p_70014_1_.setByte("pickup", (byte)this.canBePickedUp);
p_70014_1_.setDouble("damage", this.damage);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound p_70037_1_)
{
this.field_145791_d = p_70037_1_.getShort("xTile");
this.field_145792_e = p_70037_1_.getShort("yTile");
this.field_145789_f = p_70037_1_.getShort("zTile");
this.ticksInGround = p_70037_1_.getShort("life");
this.field_145790_g = Block.getBlockById(p_70037_1_.getByte("inTile") & 255);
this.inData = p_70037_1_.getByte("inData") & 255;
this.arrowShake = p_70037_1_.getByte("shake") & 255;
this.inGround = p_70037_1_.getByte("inGround") == 1;
if (p_70037_1_.hasKey("damage", 99))
{
this.damage = p_70037_1_.getDouble("damage");
}
if (p_70037_1_.hasKey("pickup", 99))
{
this.canBePickedUp = p_70037_1_.getByte("pickup");
}
else if (p_70037_1_.hasKey("player", 99))
{
this.canBePickedUp = p_70037_1_.getBoolean("player") ? 1 : 0;
}
}
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer p_70100_1_)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && p_70100_1_.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !p_70100_1_.inventory.addItemStackToInventory(new ItemStack(ModItems.itemIronTippedModelArrow, 1)))
{
flag = false;
}
if (flag)
{
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
p_70100_1_.onItemPickup(this, 1);
this.setDead();
}
}
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
* prevent them from trampling crops
*/
protected boolean canTriggerWalking()
{
return false;
}
@SideOnly(Side.CLIENT)
public float getShadowSize()
{
return 0.0F;
}
public void setDamage(double p_70239_1_)
{
this.damage = p_70239_1_;
}
public double getDamage()
{
return this.damage;
}
/**
* Sets the amount of knockback the arrow applies when it hits a mob.
*/
public void setKnockbackStrength(int p_70240_1_)
{
this.knockbackStrength = p_70240_1_;
}
/**
* If returns false, the item will not inflict any damage against entities.
*/
public boolean canAttackWithItem()
{
return false;
}
}

View File

@@ -0,0 +1,60 @@
package com.kitsu.medievalcraft.entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class EntityShit extends EntityThrowable {
public EntityShit(World world)
{
super(world);
}
public EntityShit(World world, EntityLivingBase entity)
{
super(world, entity);
}
//@SideOnly(Side.CLIENT)
public EntityShit(World world, double x, double y, double z)
{
super(world, x, y, z);
}
@Override
protected void onImpact(MovingObjectPosition object) {
if (object.entityHit != null) {
float impactDamage = 1.0F;
object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), impactDamage);
}
for (int i = 0; i < 8; ++i)
{
this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}
if (!this.worldObj.isRemote)
{
this.setDead();
//this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(ModItems.itemShit)));
}
}
@Override
public void onUpdate()
{
super.onUpdate();
}
}

View File

@@ -0,0 +1,25 @@
package com.kitsu.medievalcraft.entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class EntityShortLivedShit extends EntityItem {
public EntityShortLivedShit(World p_i1709_1_, double p_i1709_2_, double p_i1709_4_, double p_i1709_6_)
{
super(p_i1709_1_);
}
public EntityShortLivedShit(World world, double x, double y, double z,ItemStack stack) {
super(world, x, y, z, stack);
this.lifespan = 500;
}
public EntityShortLivedShit(World world)
{
super(world);
}
}

View File

@@ -0,0 +1,70 @@
package com.kitsu.medievalcraft.entity;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.item.weapon.ItemHeavyMace;
public class EntityTester extends EntityThrowable {
private Vec3 vectest;
private Vec3 vecplayer;
public EntityTester(World world)
{
super(world);
}
public EntityTester(World world, EntityLivingBase entity)
{
super(world, entity);
}
//@SideOnly(Side.CLIENT)
public EntityTester(World world, double x, double y, double z)
{
super(world, x, y, z);
}
@Override
protected void onImpact(MovingObjectPosition object) {
if(Minecraft.getMinecraft().theWorld.difficultySetting.getDifficultyId() == 3){
if(object.entityHit != null){
if((ItemHeavyMace.attack == true)){
vecplayer = ItemHeavyMace.vecp;
vectest = vectest.createVectorHelper(object.entityHit.posX, object.entityHit.posY, object.entityHit.posZ);
if((vecplayer.distanceTo(vectest) < 6)){
ItemHeavyMace.damage = true;
object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 8);
}
}
}
}
if (!this.worldObj.isRemote){
this.setDead();
//this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(ModItems.itemShit)));
}
}
@Override
public void onUpdate()
{
super.onUpdate();
}
}

View File

@@ -0,0 +1,592 @@
package com.kitsu.medievalcraft.entity;
import java.util.List;
import com.kitsu.medievalcraft.item.ModItems;
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.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class ProjectileCannonBall extends EntityArrow implements IProjectile {
private int field_145791_d = -1;
private int field_145792_e = -1;
private int field_145789_f = -1;
private Block field_145790_g;
private int inData;
private boolean inGround;
/** 1 if the player can pick up the arrow */
public int canBePickedUp;
/** Seems to be some sort of timer for animating an arrow. */
public int arrowShake;
/** The owner of this arrow. */
public Entity shootingEntity;
private int ticksInGround;
private int ticksInAir;
private double damage = 35.0D;
/** The amount of knockback an arrow applies when it hits a mob. */
private int knockbackStrength;
public ProjectileCannonBall(World world)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.setSize(0.5F, 0.5F);
}
public ProjectileCannonBall(World world, double x, double y, double z)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.setSize(0.5F, 0.5F);
this.setPosition(x, y, z);
this.yOffset = 0.0F;
}
@SuppressWarnings("cast")
public ProjectileCannonBall(World world, EntityLivingBase player, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = player;
if (player instanceof EntityPlayer)
{
this.canBePickedUp = 1;
}
this.posY = player.posY + (double)player.getEyeHeight() + 0.10000000149011612D;
double d0 = p_i1755_3_.posX - player.posX;
double d1 = p_i1755_3_.boundingBox.minY + (double)(p_i1755_3_.height / 3.0F) - this.posY;
double d2 = p_i1755_3_.posZ - player.posZ;
double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
if (d3 >= 1.0E-7D)
{
float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
double d4 = d0 / d3;
double d5 = d2 / d3;
this.setLocationAndAngles(player.posX + d4, this.posY, player.posZ + d5, f2, f3);
this.yOffset = 0.0F;
float f4 = (float)d3 * 0.2F;
this.setThrowableHeading(d0, d1 + (double)f4, d2, p_i1755_4_, p_i1755_5_);
}
}
@SuppressWarnings("cast")
public ProjectileCannonBall(World world, EntityLivingBase player, float p_i1756_3_)
{
super(world);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = player;
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, player.rotationPitch);
this.posX += (player.getLookVec().xCoord);
//this.posY -= 0.10000000149011612D;
this.posZ += (player.getLookVec().zCoord);
//this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.posY += player.getLookVec().yCoord;
if(player.getLookVec().yCoord < 0){
this.posY += player.getLookVec().yCoord * 2;
}
this.setPosition(this.posX, this.posY, this.posZ);
//this.setSize(0.5F, 0.5F);
//this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, player.rotationPitch);
//this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
//this.posY -= 0.10000000149011612D;
//this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
//this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F);
}
protected void entityInit()
{
this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
*/
@SuppressWarnings("cast")
public void setThrowableHeading(double x, double y, double z, float p_70186_7_, float p_70186_8_)
{
float f2 = MathHelper.sqrt_double(x * x + y * y + z * z);
x /= (double)f2;
y /= (double)f2;
z /= (double)f2;
x += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
y += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
z += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
x *= (double)p_70186_7_;
y *= (double)p_70186_7_;
z *= (double)p_70186_7_;
this.motionX = x/2.5;
this.motionY = y/1.75;
this.motionZ = z/2.5;
float f3 = MathHelper.sqrt_double(x * x + z * z);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI);
this.ticksInGround = 1;
}
/**
* Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
* posY, posZ, yaw, pitch
*/
@SideOnly(Side.CLIENT)
public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_)
{
this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_);
this.setRotation(p_70056_7_, p_70056_8_);
}
/**
* Sets the velocity to the args. Args: x, y, z
*/
@SuppressWarnings("cast")
@SideOnly(Side.CLIENT)
public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_)
{
this.motionX = p_70016_1_ ;
this.motionY = p_70016_3_ ;
this.motionZ = p_70016_5_ ;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch;
this.prevRotationYaw = this.rotationYaw;
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
this.ticksInGround = 0;
}
}
/**
* Called to update the entity's position/logic.
*/
@SuppressWarnings("cast")
public void onUpdate()
{
super.onUpdate();
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI);
}
Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
//this.getEntityData().setInteger("blockX", this.field_145791_d);
if (block.getMaterial() != Material.air)
{
block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
{
this.inGround = true;
}
}
if (this.arrowShake > 0)
{
--this.arrowShake;
}
if (this.inGround)
{
int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (block == this.field_145790_g && j == this.inData)
{
++this.ticksInGround;
if (this.ticksInGround == -1)
{
//this.setDead();
}
}
else
{
this.inGround = false;
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
this.ticksInGround = 0;
this.ticksInAir = 0;
}
}
else
{
++this.ticksInAir;
Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false);
vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int i;
float f1;
for (i = 0; i < list.size(); ++i)
{
Entity entity1 = (Entity)list.get(i);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
{
f1 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
if (movingobjectposition1 != null)
{
double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
this.inGround=true;
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))
{
movingobjectposition = null;
}
}
float f2;
float f4;
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
int k = MathHelper.ceiling_double_int((double)f2 * this.damage);
DamageSource damagesource = null;
if (this.shootingEntity == null)
{
//EntityPlayer player = (EntityPlayer) movingobjectposition.entityHit;
//System.out.println(player.inventory.getTotalArmorValue());
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
//damagesource = DamageSource.
}
else
{
damagesource = DamageSource.causeThrownDamage(this, this.shootingEntity);
}
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
{
movingobjectposition.entityHit.setFire(5);
}
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k))
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit;
if (!this.worldObj.isRemote)
{
//entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1);
}
if (this.knockbackStrength > 0)
{
f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f4 > 0.0F)
{
movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4);
}
}
if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase)
{
EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity);
EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase);
}
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
{
((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
}
}
//this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
if (!(movingobjectposition.entityHit instanceof EntityEnderman))
{
this.inGround = true;
}
}
else
{
this.motionX *= -0.10000000149011612D;
this.motionY *= -0.10000000149011612D;
this.motionZ *= -0.10000000149011612D;
this.rotationYaw += 180.0F;
this.prevRotationYaw += 180.0F;
this.ticksInAir = 0;
}
this.inGround=true;
}
else
{
this.field_145791_d = movingobjectposition.blockX;
this.field_145792_e = movingobjectposition.blockY;
this.field_145789_f = movingobjectposition.blockZ;
this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX));
this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY));
this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ));
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / (double)f2 * 0.05000000074505806D;
this.posY -= this.motionY / (double)f2 * 0.05000000074505806D;
this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D;
//this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
this.inGround = true;
this.arrowShake = 7;
if (this.field_145790_g.getMaterial() != Material.air)
{
this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
}
}
this.inGround=true;
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f3 = 0.99F;
f1 = 0.05F;
if (this.isInWater())
{
for (int l = 0; l < 4; ++l)
{
f4 = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
}
f3 = 0.8F;
}
if (this.isWet())
{
this.extinguish();
}
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
this.inGround=true;
}
}
this.motionX *= (double)f3;
this.motionY *= (double)f3;
this.motionZ *= (double)f3;
this.motionY -= (double)f1;
this.setPosition(this.posX, this.posY, this.posZ);
this.func_145775_I();
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound p_70014_1_)
{
p_70014_1_.setShort("xTile", (short)this.field_145791_d);
p_70014_1_.setShort("yTile", (short)this.field_145792_e);
p_70014_1_.setShort("zTile", (short)this.field_145789_f);
p_70014_1_.setShort("life", (short)this.ticksInGround);
p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g));
p_70014_1_.setByte("inData", (byte)this.inData);
p_70014_1_.setByte("shake", (byte)this.arrowShake);
p_70014_1_.setByte("inGround", (byte)(this.inGround ? 1 : 0));
p_70014_1_.setByte("pickup", (byte)this.canBePickedUp);
p_70014_1_.setDouble("damage", this.damage);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound p_70037_1_)
{
this.field_145791_d = p_70037_1_.getShort("xTile");
this.field_145792_e = p_70037_1_.getShort("yTile");
this.field_145789_f = p_70037_1_.getShort("zTile");
this.ticksInGround = p_70037_1_.getShort("life");
this.field_145790_g = Block.getBlockById(p_70037_1_.getByte("inTile") & 255);
this.inData = p_70037_1_.getByte("inData") & 255;
this.arrowShake = p_70037_1_.getByte("shake") & 255;
this.inGround = p_70037_1_.getByte("inGround") == 1;
if (p_70037_1_.hasKey("damage", 99))
{
this.damage = p_70037_1_.getDouble("damage");
}
if (p_70037_1_.hasKey("pickup", 99))
{
this.canBePickedUp = p_70037_1_.getByte("pickup");
}
else if (p_70037_1_.hasKey("player", 99))
{
this.canBePickedUp = p_70037_1_.getBoolean("player") ? 1 : 0;
}
}
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer p_70100_1_)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && p_70100_1_.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !p_70100_1_.inventory.addItemStackToInventory(new ItemStack(ModItems.itemITSpear, 1)))
{
flag = false;
}
if (flag)
{
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
p_70100_1_.onItemPickup(this, 1);
this.setDead();
}
}
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
* prevent them from trampling crops
*/
protected boolean canTriggerWalking()
{
return false;
}
@SideOnly(Side.CLIENT)
public float getShadowSize()
{
return 2.0F;
}
public void setDamage(double p_70239_1_)
{
this.damage = p_70239_1_;
}
public double getDamage()
{
return this.damage;
}
/**
* Sets the amount of knockback the arrow applies when it hits a mob.
*/
public void setKnockbackStrength(int p_70240_1_)
{
this.knockbackStrength = p_70240_1_;
}
/**
* If returns false, the item will not inflict any damage against entities.
*/
public boolean canAttackWithItem()
{
return true;
}
}

View File

@@ -0,0 +1,221 @@
package com.kitsu.medievalcraft.entityAI;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityWaterMob;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.profiler.Profiler;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.ChunkCache;
import net.minecraft.world.World;
public class EntityAIWaterMob extends EntityWaterMob implements IAnimals{
protected int attackInterval = 50;
protected float attackSpeed = 1.2F;
protected float swimSpeed = 0.5F;
private double targetX;
private double targetY;
private double targetZ;
private Entity targetedEntity;
private boolean isAttacking;
protected float swimRadius = 4.0F;
protected float swimRadiusHeight = 4.0F;
protected boolean Agrooed = false;
protected boolean landBounce = true;
protected float moreDamage = 0.5F;
public Profiler theProfiler;
public EntityAIWaterMob(World world)
{
super(world);
this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntitySquid.class, 32, true, true, IMob.mobSelector));
}
protected boolean canTriggerWalking()
{
return false;
}
protected boolean isAIEnabled()
{
return true;
}
public boolean canBreatheUnderwater()
{
return true;
}
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}
public void onUpdate()
{
super.onUpdate();
if (isInWater()) {
this.motionY *= 0.1D;
}
}
public void applyEntityCollision(Entity entity)
{
super.applyEntityCollision(entity);
if ((this.Agrooed) && (this.targetedEntity == entity))
{
attackEntityAsMob(entity);
}
}
protected Entity findPreyHuman()
{
EntityPlayer player = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
return (player != null) && (canEntityBeSeen(player)) ? player : null;
}
public boolean attackEntityAsMob(Entity entity)
{
float f = (float)getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
return entity.attackEntityFrom(DamageSource.causeMobDamage(this), f + moreDamage);
}
public void onEntityUpdate()
{
int air = getAir();
super.onEntityUpdate();
if ((isEntityAlive()) && (!isInWater()))
{
air--;
setAir(air);
if (getAir() == -20)
{
setAir(0);
attackEntityFrom(DamageSource.drown, 2.0F);
}
}
else
{
setAir(300);
}
}
protected void updateAITasks()
{
super.updateAITasks();
if (isInWater())
{
double dx = this.targetX - this.posX;
double dy = this.targetY - this.posY;
double dz = this.targetZ - this.posZ;
double dist = MathHelper.sqrt_double(dx * dx + dy * dy + dz * dz);
if ((dist < 1.0D) || (dist > 1000.0D))
{
this.targetX = (this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.targetY = (this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadiusHeight);
this.targetZ = (this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * this.swimRadius);
this.isAttacking = false;
}
if (this.worldObj.getBlock(MathHelper.floor_double(this.targetX), MathHelper.floor_double(this.targetY + this.height), MathHelper.floor_double(this.targetZ)).getMaterial() == Material.water)
{
this.motionX += dx / dist * 0.05D * this.swimSpeed;
this.motionY += dy / dist * 0.1D * this.swimSpeed;
this.motionZ += dz / dist * 0.05D * this.swimSpeed;
}
else
{
this.targetX = this.posX;
this.targetY = (this.posY + 0.1D);
this.targetZ = this.posZ;
}
if (this.isAttacking)
{
this.motionX *= this.attackSpeed;
this.motionY *= this.attackSpeed;
this.motionZ *= this.attackSpeed;
}
if ((this.Agrooed) && (this.rand.nextInt(this.attackInterval) == 0))
{
this.targetedEntity = findPreyHuman();
if ((this.targetedEntity != null) && (this.targetedEntity.isInWater()))
{
this.targetX = this.targetedEntity.posX;
this.targetY = this.targetedEntity.posY;
this.targetZ = this.targetedEntity.posZ;
this.isAttacking = true;
}
}
this.renderYawOffset += (-(float)Math.atan2(this.motionX, this.motionZ) * 180.0F / 3.141593F - this.renderYawOffset) * 0.5F;
this.rotationYaw = this.renderYawOffset;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationPitch += ((float)Math.atan2(this.motionY, f) * 180.0F / 3.141593F - this.rotationPitch) * 0.5F;
}
else
{
this.motionX = 0.0D;
this.motionY -= 0.08D;
this.motionY *= 0.9800000190734863D;
this.motionZ = 0.0D;
if ((this.landBounce) && (this.onGround) && (this.rand.nextInt(30) == 0))
{
this.motionY = 0.300000011920929D;
this.motionX = (-0.4F + this.rand.nextFloat() * 0.8F);
this.motionZ = (-0.4F + this.rand.nextFloat() * 0.8F);
}
}
}
}
/*when you extend it,
you want to add these to your constructor:
this.Agrooed = true;
this.swimRadius = 25F;
this.swimSpeed = 0.5F;
this.attackInterval = 23;
this.landBounce = true;
what these stand for are pretty self explanitory. add this to your class:
@Override
protected Entity findPrey()
{
AxisAlignedBB area = this.boundingBox.expand(16.0D, 16.0D, 16.0D);
EntityPlayer player = (EntityPlayer)super.findPrey();
if (player != null) {
return player;
}
return worldObj.findNearestEntityWithinAABB(EntityPlayer.class, area, this);
*/

View File

@@ -0,0 +1,46 @@
package com.kitsu.medievalcraft.events;
import java.util.HashMap;
import java.util.Map;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.eventhandler.Event.Result;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.FillBucketEvent;
public class BucketHandle {
public static BucketHandle INSTANCE = new BucketHandle();
public Map<Block, Item> buckets = new HashMap<Block, Item>();
private BucketHandle() {
}
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {
ItemStack result = fillCustomBucket(event.world, event.target);
if (result == null)
return;
event.result = result;
event.setResult(Result.ALLOW);
}
private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) {
Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
Item bucket = buckets.get(block);
if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) {
world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
return new ItemStack(bucket);
} //else
return null;
}
}

View File

@@ -0,0 +1,652 @@
package com.kitsu.medievalcraft.events;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.event.MouseEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.item.ItemEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.item.craftingtools.ForgeHammer;
import com.kitsu.medievalcraft.util.ShieldSwitchTable;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class EventHandle {
//private int wKey, sKey;
//public static int longbowD;
public int longbowTicks;
//public static boolean longbowUse;
public static boolean mobcheck, weaponUse;
Random rand = new Random();
/*@SubscribeEvent
public void zombieJoinsEvent(EntityJoinWorldEvent event){
if(event.entity instanceof EntityRazorBack){
event.entity.po
System.out.println(event.entity.posX + ":" + event.entity.posy + ":" + event.entity.posZ);
}
}*/
@SubscribeEvent
public void ironOreJungleEvent (HarvestDropsEvent event){
if(BiomeDictionary.isBiomeOfType(event.world.getBiomeGenForCoords(event.x, event.z), Type.JUNGLE)){
if(event.block.equals(Blocks.iron_ore)){
event.drops.clear();
ItemStack testStack = new ItemStack(ModBlocks.wootzOre);
event.drops.add(testStack);
}
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void longbowUseEvent (PlayerUseItemEvent.Tick event) {
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
if(player.worldObj.isRemote == true){
if(player.getItemInUse().getItem().equals(ModItems.longbow)){
longbowTicks = player.getItemInUseDuration();
ItemStack stack = player.inventory.getCurrentItem();
if((longbowTicks > 0) && (longbowTicks <=5)){
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 1);
}
if((longbowTicks > 5) && (longbowTicks <=10)){
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 2);
}
if((longbowTicks > 10) && (longbowTicks <=15)){
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 3);
}
if((longbowTicks > 15) && (longbowTicks <=20)){
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 4);
}
if((longbowTicks > 20) && (longbowTicks <=25)){
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 5);
}
if((longbowTicks > 25) && (longbowTicks <=30)){
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 6);
}
if((longbowTicks > 30) && (longbowTicks <=35)){
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 7);
}
if((longbowTicks > 35) && (longbowTicks <=40)){
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 8);
}
if((longbowTicks > 40) && (longbowTicks <=45)){
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 9);
}
if(longbowTicks == 45){
player.playSound((Main.MODID + ":tautBow"), 0.8F, 1.0F);
//player.worldObj.playSoundAtEntity(player, (Main.MODID + ":tautBow"), 0.8F, 1.0F);
}
if((longbowTicks > 45) && (longbowTicks <=55)){
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 10);
}
if((longbowTicks > 100)){
longbowTicks = 100;
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setInteger("D", 10);
}
}
}
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void getMouseEvent(MouseEvent event){
if((event.button == 0) && (event.buttonstate == true)){
ForgeHammer.forgeHammerLeftClick = true;
}
if(event.buttonstate == false){
ForgeHammer.forgeHammerLeftClick = false;
}
//System.out.println("Button: " + event.button);
//System.out.println("ButtonState: " + event.buttonstate);
}
/*@SubscribeEvent
public void splitLogEvent(PlayerInteractEvent event){
if(event.entityPlayer instanceof EntityPlayer){
EntityPlayer player = event.entityPlayer;
if((event.useBlock.equals(ModBlocks.cleanAcacia))
||(event.useBlock.equals(ModBlocks.cleanBirch))
||(event.useBlock.equals(ModBlocks.cleanDarkOak))
||(event.useBlock.equals(ModBlocks.cleanJungle))
||(event.useBlock.equals(ModBlocks.cleanOak))
||(event.useBlock.equals(ModBlocks.cleanSpruce))){
System.out.println("Player Used Wood");
if(player.inventory.getCurrentItem()!=null){
System.out.println(player.inventory.getCurrentItem().getClass());
if(player.getItemInUse().getItem() instanceof ItemAxe){
player.swingItem();
if(!event.world.isRemote){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.splitLog, 0, 2);
}
}
}
}
}
}*/
@SubscribeEvent
public void emptyHandBarkEvent(PlayerInteractEvent event) {
if(!event.entity.worldObj.isRemote){
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
if(player.inventory.getCurrentItem()!=null){
Block test = event.world.getBlock(event.x, event.y, event.z);
//Block isEmpty = event.world.getBlock(event.x, event.y + 1, event.z);
ItemStack itemStack = new ItemStack(ModItems.itemBark);
//ItemStack stickStack = new ItemStack(Items.stick);
if((player.inventory.getCurrentItem().getItem() == Items.stick)) {
if((event.action == event.action.RIGHT_CLICK_BLOCK ) && ((test == Blocks.log)||test == Blocks.log2) ) { //&& (test == ModBlocks.testForge) && (isEmpty == Blocks.air)
if(test == Blocks.log){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":scrapes1", 0.15F, 0.85F);
int woodMeta = event.world.getBlockMetadata(event.x,event.y, event.z);
if(woodMeta == 0 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanOak, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 4 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanOak, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 8 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanOak, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 1 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanSpruce, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 5 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanSpruce, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 9 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanSpruce, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 2 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanBirch, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 6 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanBirch, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 10 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanBirch, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 3 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanJungle, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 7 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanJungle, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 11 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanJungle, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
}
if(test == Blocks.log2){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":scrapes1", 0.2F, 0.8F);
int woodMeta = event.world.getBlockMetadata(event.x, event.y, event.z);
if(woodMeta == 0 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanAcacia, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 4 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanAcacia, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 8 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanAcacia, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 1 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanDarkOak, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 5 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanDarkOak, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 9 && event.world.rand.nextInt(9)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanDarkOak, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 1 + event.world.rand.nextInt(2), 0)));
}
}
}
}
}
}
}
}
/*@SubscribeEvent
public void flintKnappedEvent(PlayerInteractEvent event) {
if(!event.entity.worldObj.isRemote){
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
Block test = event.world.getBlock(event.x, event.y, event.z);
ItemStack flint = new ItemStack(Items.flint);
ItemStack flintKnapped = new ItemStack(ModItems.flintKnapped, 1 + event.world.rand.nextInt(3), 0);
//if(player.isSneaking()){
if((player.inventory.getCurrentItem() != null)) {
if((player.inventory.getCurrentItem().getItem().equals(Items.flint)) && (test==Blocks.stone)){
if(player.isSwingInProgress == false){
player.worldObj.playSoundAtEntity(player, "mob.chicken.step", 1.0f, 1.0f);
player.swingItem();
if((event.world.rand.nextInt(4)==0)){
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
if((event.world.rand.nextInt(2)==0)){
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y+1, event.z, flintKnapped));
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
}
}
}*/
@SubscribeEvent
public void flintHandBarkEvent(PlayerInteractEvent event) {
if(!event.entity.worldObj.isRemote){
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
Block test = event.world.getBlock(event.x, event.y, event.z);
//Block isEmpty = event.world.getBlock(event.x, event.y + 1, event.z);
ItemStack itemStack = new ItemStack(ModItems.itemBark);
ItemStack flint = new ItemStack(ModItems.flintKnapped);
//if(player.isSneaking()){
if((player.inventory.getCurrentItem() != null)) {
if((player.inventory.getCurrentItem().getUnlocalizedName().contains("flintKnapped"))){
if((event.action == event.action.RIGHT_CLICK_BLOCK ) && ((test == Blocks.log)||test == Blocks.log2)) {
if(test == Blocks.log){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":scrapes1", 0.15F, 0.85F);
int woodMeta = event.world.getBlockMetadata(event.x,event.y, event.z);
if(woodMeta == 0 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanOak, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 4 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanOak, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 8 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanOak, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 1 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanSpruce, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 5 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanSpruce, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 9 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanSpruce, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 2 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanBirch, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 6 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanBirch, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 10 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanBirch, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 3 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanJungle, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 7 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanJungle, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 11 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y,event.z, ModBlocks.cleanJungle, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
}
if(test == Blocks.log2){
player.worldObj.playSoundAtEntity(player, Main.MODID + ":scrapes1", 0.2F, 0.8F);
int woodMeta = event.world.getBlockMetadata(event.x, event.y, event.z);
if(woodMeta == 0 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanAcacia, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 4 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanAcacia, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 8 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanAcacia, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 1 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanDarkOak, 0, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 5 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanDarkOak, 4, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
if(woodMeta == 9 && event.world.rand.nextInt(6)==0){
event.world.setBlock(event.x, event.y, event.z, ModBlocks.cleanDarkOak, 8, 2);
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x, event.y, event.z, new ItemStack(ModItems.itemBark, 2 + event.world.rand.nextInt(2), 0)));
}
}
if(event.world.rand.nextInt(50)==0){
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
}
}
}
}
}
@SubscribeEvent
public void myDiamondPlayerInteractEvent(PlayerInteractEvent event) {
if(!event.entity.worldObj.isRemote){
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
ItemStack itemStack = new ItemStack(Items.diamond);
if(player.isSneaking()){
if((player.inventory.getCurrentItem() != null)) {
if((player.inventory.getCurrentItem().getItem().equals(Items.diamond))){
if((event.action == event.action.RIGHT_CLICK_BLOCK )){
if(event.world.getBlock(event.x, event.y + 1, event.z).equals(Blocks.air)){
event.world.setBlock(event.x, event.y + 1, event.z, ModBlocks.myDiamond, 0, 2);
//event.world.setBlock(event.x, event.y+1, event.z, Blocks.bedrock);
player.inventory.consumeInventoryItem(Items.diamond);
}
}
}
}
}
}
}
}
@SubscribeEvent
public void myEmeraldPlayerInteractEvent(PlayerInteractEvent event) {
if(!event.entity.worldObj.isRemote){
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
//Block test = event.world.getBlock(event.x, event.y, event.z);
//Block isEmpty = event.world.getBlock(event.x, event.y + 1, event.z);
ItemStack itemStack = new ItemStack(Items.emerald);
if(player.isSneaking()){
if((player.inventory.getCurrentItem() != null)) {
if((player.inventory.getCurrentItem().isItemEqual(itemStack)) && (player.inventory.getStackInSlot(player.inventory.currentItem).stackSize >= 2)){
if((event.action == event.action.RIGHT_CLICK_BLOCK ) ) { //&& (test == ModBlocks.testForge) && (isEmpty == Blocks.air)
if(event.world.getBlock(event.x, event.y + 1, event.z).equals(Blocks.air)){
player.inventory.decrStackSize(player.inventory.currentItem, 1);
event.world.setBlock(event.x, event.y + 1, event.z, ModBlocks.myEmerald, 0, 2);
player.inventory.consumeInventoryItem(Items.emerald);
}
}
}
}
}
}
}
}
/*@SubscribeEvent
public void onItemShitJoinEvent(ItemEvent event){
if(!event.entity.worldObj.isRemote){
if(event.entity.getgetEntityItem().getItem() == ModItems.itemShit){
//System.out.println(event.entityItem.worldObj.getBlock((int)event.entityItem.posX, (int)event.entityItem.posY-2, (int)event.entityItem.posZ));
/*if(event.entityItem.worldObj.getBlock((int)event.entityItem.posX, (int)event.entityItem.posY-1, (int)event.entityItem.posZ)==Blocks.grass){
event.entityItem.setDead();
}
event.lifespan=200;
}
}
}*/
@SubscribeEvent
public void onLivingUpdateEventShit(LivingUpdateEvent event) {
//eventLongbowTicks = ItemLongbow.longbowTicks;
//System.out.println(eventLongbowTicks);
//MAKE COWS SHIT
//Differentiates Client and Server
if (!event.entity.worldObj.isRemote) {
//Default to 100000
if ( rand.nextInt(1500) == 0 ) {
//Checks to see if the LivingUpdate is being applied to cow, if so:
if (event.entity instanceof EntityCow) {
event.entityLiving.dropItem(ModItems.itemShit, 1);
}
}
}
}
/*
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onLivingUpdateLongSword (LivingUpdateEvent event) {
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
if (player.isUsingItem() == true) {
useItem = player.inventory.getCurrentItem();
j = useItem.getItemDamage();
if(useItem.isItemEqual(new ItemStack(ModItems.longSword, OreDictionary.WILDCARD_VALUE, j))) {
player.inventory.changeCurrentItem(1);
if (player.inventory.getCurrentItem() != null) {
switchedItem = player.inventory.getCurrentItem();
i = switchedItem.getItemDamage();
if ((switchedItem.isItemEqual(new ItemStack(ModItems.woodenShield, OreDictionary.WILDCARD_VALUE, i))) || (switchedItem.isItemEqual(new ItemStack(ModItems.ironShield, OreDictionary.WILDCARD_VALUE, i)))){
} else player.inventory.changeCurrentItem(-1);
} else player.inventory.changeCurrentItem(-1);
}
}
}
}*/
/*@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPlayerUpdateMaceWoodenShield (LivingUpdateEvent event) {
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
if (player.isUsingItem() == true) {
useItem2 = player.inventory.getCurrentItem();
j = useItem2.getItemDamage();
if(useItem2.isItemEqual(new ItemStack(ModItems.heavyMace, OreDictionary.WILDCARD_VALUE, j))) {
player.inventory.changeCurrentItem(1);
if (player.inventory.getCurrentItem() != null) {
switchedItem2 = player.inventory.getCurrentItem();
i = switchedItem2.getItemDamage();
if ((switchedItem2.isItemEqual(new ItemStack(ModItems.woodenShield, OreDictionary.WILDCARD_VALUE, i))) || (switchedItem2.isItemEqual(new ItemStack(ModItems.ironShield, OreDictionary.WILDCARD_VALUE, i)))){
} else player.inventory.changeCurrentItem(-1);
} else player.inventory.changeCurrentItem(-1);
}
}
}
}*/
/*
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void SwordToShieldSwitch (LivingUpdateEvent event) {
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
if(player.isUsingItem() == true){
if((checkWeapon(player.getItemInUse().getItem())) == true){
if(weaponUse == true){
if(player.inventory.currentItem != 0){
int a = player.inventory.currentItem;
if(player.inventory.getStackInSlot(a-1) != null){
if((checkShield(player.inventory.getStackInSlot(a-1).getItem())) == true){
player.inventory.changeCurrentItem(+1);
weaponUse = false;
}
}
}
}
}
}
}
}
private boolean checkWeapon(Item testItem){
for(int i = 0; i < ShieldSwitchTable.weapons.size(); i++){
if(testItem == ShieldSwitchTable.weapons.get(i)){
return true;
}
}
return false;
}
private Boolean checkShield(Item testItem){
for(int i = 0; i < ShieldSwitchTable.shields.size(); i++){
if(testItem == ShieldSwitchTable.shields.get(i)){
return true;
}
}
return false;
}
@SubscribeEvent
public void onPlayerHurtShield (LivingHurtEvent event) {
if(event.entity.worldObj.isRemote){
if (event.entity instanceof EntityPlayer && event.ammount > 0) {
EntityPlayer player = (EntityPlayer) event.entity;
Entity mobEntity = event.source.getEntity();
String mobString = event.source.getDamageType();
//System.out.println(mobEntity);
//System.out.println(mobString);
if (player.inventory.getCurrentItem()!=null){
if(player.isUsingItem()==true){
if (player.inventory.getCurrentItem()!=null){
if (player.inventory.getCurrentItem().getItem().equals(checkShield(player.inventory.getCurrentItem().getItem()))) {
if ((mobString.equals("explosion")) || (mobString.equals("thrown")) || (mobString.equals("arrow") || (mobString.equals("player")) || (mobString.equals("mob")) || (mobString.equals("fireball")))) {
Vec3 vec3 = player.getLook(1.0F).normalize();
Vec3 vec31 = Vec3.createVectorHelper(mobEntity.posX - player.posX, mobEntity.boundingBox.minY + mobEntity.height / 2.0F - (player.posY + player.getEyeHeight()), mobEntity.posZ - player.posZ);
double d0 = vec31.lengthVector();
vec31 = vec31.normalize();
double d1 = vec3.dotProduct(vec31);
double d2 = 1.0D - 0.025D / d0;
if (d1 + 0.3 > d2) {
if(player.inventory.getCurrentItem().getItem().equals(ModItems.woodenShield)){
if(event.ammount > 1.5F){
event.ammount = event.ammount-2F;
} else event.ammount = 0;
player.getCurrentEquippedItem().damageItem(2, player);
player.worldObj.playSoundAtEntity(player, Main.MODID + ":woodshieldbash", 1.0F, 1.0F);
//event.entityLiving.addPotionEffect(new PotionEffect(Potion.resistance.id, 60, 0, true));
if (mobString.equals("explosion") && rand.nextInt(5) == 1) {
--player.getCurrentEquippedItem().stackSize;
}
}
if(player.inventory.getCurrentItem().getItem().equals(ModItems.ironShield)){
if(event.ammount > 4F){
event.ammount = event.ammount-4F;
} else event.ammount = 0;
player.getCurrentEquippedItem().damageItem(4, player);
player.worldObj.playSoundAtEntity(player, Main.MODID + ":ironShieldBash", 1.0F, 1.0F);
}
}
}
}
}
}
}
}
}
}
*/
}

View File

@@ -0,0 +1,38 @@
package com.kitsu.medievalcraft.gui;
import org.lwjgl.opengl.GL11;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.contain.ContainerCannon_28;
import com.kitsu.medievalcraft.tileents.cannon.TileCannon_28;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
public class GuiCannon_28 extends GuiContainer {
private ResourceLocation texture = new ResourceLocation(Main.MODID + ":" + "textures/gui/cannongui.png");
public GuiCannon_28(InventoryPlayer inventoryPlayer, TileCannon_28 tileEntity) {
super(new ContainerCannon_28(inventoryPlayer, tileEntity));
// TODO Auto-generated constructor stub
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
//String name = "Forge";
//this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
//this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
GL11.glColor4f(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}
}

View File

@@ -0,0 +1,38 @@
package com.kitsu.medievalcraft.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.contain.ContainerForgeAnvil;
import com.kitsu.medievalcraft.tileents.machine.TileEntityAnvilForge;
public class GuiForgeAnvil extends GuiContainer {
private ResourceLocation texture = new ResourceLocation(Main.MODID + ":" + "textures/gui/forgeovengui.png");
public GuiForgeAnvil(InventoryPlayer inventoryPlayer, TileEntityAnvilForge tileEntity) {
super(new ContainerForgeAnvil(inventoryPlayer, tileEntity));
// TODO Auto-generated constructor stub
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
//String name = "Forge";
//this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
//this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
GL11.glColor4f(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}
}

View File

@@ -0,0 +1,48 @@
package com.kitsu.medievalcraft.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.contain.ContainerFormTable;
public class GuiFormTable extends GuiContainer {
private ResourceLocation texture = new ResourceLocation(Main.MODID + ":" + "textures/gui/formtablegui.png");
public GuiFormTable(InventoryPlayer playerinv, World world, int x, int y, int z) {
super(new ContainerFormTable(playerinv, world, x, y, z));
this.xSize = 200;
this.ySize = 200;
}
public void onGuiClosed(){
super.onGuiClosed();
}
protected void drawGuiContainerForegroundLayer(int i, int j) {
//Name xstart ystart color
this.fontRendererObj.drawString(StatCollector.translateToLocal("Form Table"), 100, 5, 0xFFFFFF);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
GL11.glColor4f(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}
}

View File

@@ -0,0 +1,76 @@
package com.kitsu.medievalcraft.gui;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.contain.ContainerCannon_28;
import com.kitsu.medievalcraft.contain.ContainerForgeAnvil;
import com.kitsu.medievalcraft.contain.ContainerFormTable;
import com.kitsu.medievalcraft.contain.ContainerSolidFilter;
import com.kitsu.medievalcraft.contain.ContainerTestForge;
import com.kitsu.medievalcraft.tileents.cannon.TileCannon_28;
import com.kitsu.medievalcraft.tileents.machine.TileEntityAnvilForge;
import com.kitsu.medievalcraft.tileents.machine.TileEntitySolidFilter;
import com.kitsu.medievalcraft.tileents.machine.TileEntityTestForge;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class GuiHandler implements IGuiHandler {
public static final int guiIDformTable = 1;
public static final int guiIDforge = 2;
public static final int guiIDforgeAnvil = 3;
public static final int guiIDsolidFilter = 4;
public static final int guiIDcannon28 = 5;
//returns an instance of the Container you made earlier
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity entity = world.getTileEntity(x, y, z);
if (id == guiIDformTable) {
return id == guiIDformTable && world.getBlock(x, y, z) == ModBlocks.formtable ? new ContainerFormTable(player.inventory, world, x, y, z) : null;
}
if (entity instanceof TileEntityTestForge) {
return new ContainerTestForge(player.inventory, (TileEntityTestForge) entity);
}
if (entity instanceof TileEntityAnvilForge) {
return new ContainerForgeAnvil(player.inventory, (TileEntityAnvilForge) entity);
}
if (entity instanceof TileEntitySolidFilter) {
return new ContainerSolidFilter(player.inventory, (TileEntitySolidFilter) entity);
}
if (entity instanceof TileCannon_28) {
return new ContainerCannon_28(player.inventory, (TileCannon_28) entity);
}
return null;
}
//returns an instance of the Gui you made earlier
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity entity = world.getTileEntity(x, y, z);
if (id == guiIDformTable) {
return id == guiIDformTable && world.getBlock(x, y, z) == ModBlocks.formtable ? new GuiFormTable(player.inventory, world, x, y, z) : null;
}
if (entity instanceof TileEntityTestForge) {
return new GuiTestForge(player.inventory, (TileEntityTestForge) entity);
}
if (entity instanceof TileEntityAnvilForge) {
return new GuiForgeAnvil(player.inventory, (TileEntityAnvilForge) entity);
}
if (entity instanceof TileEntitySolidFilter) {
return new GuiSolidFilter(player.inventory, (TileEntitySolidFilter) entity);
}
if (entity instanceof TileCannon_28) {
return new GuiCannon_28(player.inventory, (TileCannon_28) entity);
}
return null;
}
}

View File

@@ -0,0 +1,40 @@
package com.kitsu.medievalcraft.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.contain.ContainerSolidFilter;
import com.kitsu.medievalcraft.tileents.machine.TileEntitySolidFilter;
public class GuiSolidFilter extends GuiContainer {
private ResourceLocation texture = new ResourceLocation(Main.MODID + ":" + "textures/gui/solidfiltergui.png");
public GuiSolidFilter(InventoryPlayer inventoryPlayer, TileEntitySolidFilter tileEntity) {
super(new ContainerSolidFilter(inventoryPlayer, tileEntity));
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
//String name = "28lb Cannon";
//this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
//this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
GL11.glColor4f(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}
}

View File

@@ -0,0 +1,38 @@
package com.kitsu.medievalcraft.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.contain.ContainerTestForge;
import com.kitsu.medievalcraft.tileents.machine.TileEntityTestForge;
public class GuiTestForge extends GuiContainer {
private ResourceLocation texture = new ResourceLocation(Main.MODID + ":" + "textures/gui/forgeovengui.png");
public GuiTestForge(InventoryPlayer inventoryPlayer, TileEntityTestForge tileEntity) {
super(new ContainerTestForge(inventoryPlayer, tileEntity));
// TODO Auto-generated constructor stub
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
//String name = "Forge";
//this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
//this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
GL11.glColor4f(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}
}

View File

@@ -0,0 +1,13 @@
package com.kitsu.medievalcraft.item;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBucket;
public class FluidBucket extends ItemBucket {
public FluidBucket(Block p_i45331_1_) {
super(p_i45331_1_);
}
}

View File

@@ -0,0 +1,65 @@
/*package com.kitsu.medievalcraft.item;
import com.kitsu.medievalcraft.CustomTab;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemEditableBook;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
public class ItemClayFormBook extends ItemEditableBook {
private String name = "clayFormBook";
public ItemClayFormBook()
{
super();
setCreativeTab(CustomTab.MedievalCraftTab);
this.setUnlocalizedName(name);
LanguageRegistry.addName(this, name);
this.setTextureName(name);
this.setMaxStackSize(1);
GameRegistry.registerItem(this, name);
}
private NBTTagList putTableOfContents(NBTTagList bookTagList) {
// Create NBT data and add to the book
NBTTagCompound tag = new NBTTagCompound();
NBTTagList bookPages = new NBTTagList();
bookTagList.appendTag(new NBTTagString("Test Book"));
return bookTagList;
}
@Override
public void onUpdate(ItemStack itemStack, World world, Entity entity, int unknownInt, boolean unknownBool)
{
NBTTagList bookTagList = new NBTTagList();
bookTagList = putTableOfContents(bookTagList);
itemStack.setTagInfo("pages", bookTagList);
itemStack.setTagInfo("author", new NBTTagString("delpi"));
itemStack.setTagInfo("title", new NBTTagString("Cloth Uses"));
}
}
/*
@Override
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) {
//stack = new ItemStack(ModItems.clayFormBook);
player.displayGUIBook(stack);
return super.onItemRightClick(stack, world, player);
}*/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
package com.kitsu.medievalcraft.item;
import java.util.Hashtable;
import com.kitsu.medievalcraft.block.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
public class TongsDamageTable {
public static final Hashtable<Block, Integer> blockToStore = new Hashtable <Block, Integer>(){{
put(ModBlocks.crucibleIronOre, 1);
put(ModBlocks.crucibleIronIngot, 2);
put(ModBlocks.crucibleLapis, 3);
put(ModBlocks.crucibleRedstone, 4);
put(ModBlocks.crucibleWootz, 5);
put(ModBlocks.lapisIngot, 6);
put(ModBlocks.redstoneIngot, 7);
put(ModBlocks.damascus, 8);
put(ModBlocks.refinedIron, 9);
put(ModBlocks.ironPlate, 10);
}};
public static final Hashtable<Integer, Block> blockToGet = new Hashtable <Integer, Block>(){{
put(1, ModBlocks.crucibleIronOre);
put(2, ModBlocks.crucibleIronIngot);
put(3, ModBlocks.crucibleLapis);
put(4, ModBlocks.crucibleRedstone);
put(5, ModBlocks.crucibleWootz);
put(6, ModBlocks.lapisIngot);
put(7, ModBlocks.redstoneIngot);
put(8, ModBlocks.damascus);
put(9, ModBlocks.refinedIron);
put(10, ModBlocks.ironPlate);
//put(11, ModBlocks.hotDamascusIngot);
//put(12, ModBlocks.hotIronPlate);
//put(13, ModBlocks.hotLapisIngot);
//put(14, ModBlocks.hotRedstoneIngot);
}};
}

View File

@@ -0,0 +1,87 @@
package com.kitsu.medievalcraft.item.craftingtools;
import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.common.registry.GameRegistry;
public class FireBow extends Item {
private String name = "fireBow";
private Item item;
Random rand = new Random();
public FireBow() {
setMaxStackSize(1);
setUnlocalizedName(name);
setCreativeTab(CustomTab.MedievalCraftTab);
setTextureName(Main.MODID + ":" + name);
setMaxDamage(100);
setNoRepair();
item = this;
GameRegistry.registerItem(this, name);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_){
if(!world.isRemote){
if(rand.nextInt(5) == 0){
world.setBlock(x, y + 1, z , Blocks.fire);
stack.damageItem(1, player);
//player.worldObj.playSoundAtEntity(player, Main.MODID + ":anvilhammer", 1.0F, 1.0F);
/*for(int i=0; i < player.worldObj.playerEntities.size(); i++){
EntityPlayer test = (EntityPlayer) player.worldObj.playerEntities.get(i);
Vec3 vecTest = Vec3.createVectorHelper(test.posX, test.posY, test.posZ);
Vec3 vecPlayer = Vec3.createVectorHelper(player.posX, player.posY, player.posZ);
if(vecPlayer.distanceTo(vecTest)>10f && vecPlayer.distanceTo(vecTest)<100f){
test.worldObj.playSoundAtEntity(test, Main.MODID + ":anvilhammer", 1.0F, 1.0F);
}
}*/
}
}
return true;
}
@Override
public int getItemEnchantability () {
return 0;
}
@Override
public boolean getIsRepairable(ItemStack item, ItemStack repair){
return Items.stick == repair.getItem() ? true : false;
}
@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemstack) {
return false;
}
@Override
public Item getContainerItem()
{
item.setDamage(new ItemStack(item), +1);
return item;
}
}

View File

@@ -0,0 +1,43 @@
package com.kitsu.medievalcraft.item.craftingtools;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.common.registry.GameRegistry;
public class FlintSaw extends Item {
private String name = "flintSaw";
private Item item;
public FlintSaw() {
setMaxStackSize(1);
setUnlocalizedName(name);
setCreativeTab(CustomTab.MedievalCraftTab);
setTextureName(Main.MODID + ":" + name);
setMaxDamage(128);
setNoRepair();
item = this;
GameRegistry.registerItem(this, name);
}
@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemstack) {
return false;
}
@Override
public Item getContainerItem()
{
item.setDamage(new ItemStack(item), +1);
return item;
}
public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_)
{
return false;
}
}

View File

@@ -0,0 +1,343 @@
package com.kitsu.medievalcraft.item.craftingtools;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import com.kitsu.medievalcraft.Main;
import com.kitsu.medievalcraft.block.ModBlocks;
import com.kitsu.medievalcraft.block.ingots.IngotBase;
import com.kitsu.medievalcraft.crafting.ForgeAnvilCrafting;
import com.kitsu.medievalcraft.crafting.TestForgeCrafting;
import com.kitsu.medievalcraft.item.ModItems;
import com.kitsu.medievalcraft.item.forms.clay.ClayForms;
import com.kitsu.medievalcraft.item.forms.iron.IronForms;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgPacket;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgPacketLocX;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgPacketLocY;
import com.kitsu.medievalcraft.packethandle.forgeHammerParticles.MsgPacketLocZ;
import com.kitsu.medievalcraft.tileents.ingots.TileIngotBase;
import com.kitsu.medievalcraft.tileents.ingots.TileIronPlate;
import com.kitsu.medievalcraft.tileents.ingots.TileMyIronIngot;
import com.kitsu.medievalcraft.tileents.machine.TileEntityAnvilForge;
import com.kitsu.medievalcraft.util.AnvilUtil;
import com.kitsu.medievalcraft.util.CustomTab;
import cpw.mods.fml.common.registry.GameRegistry;
public class ForgeHammer extends Item implements AnvilUtil{
private String name = "forgeHammer";
private Item item;
//private Block test;
private int hit, key, blockKey, keys;
public static boolean forgeHammerLeftClick;
TileMyIronIngot tileRefIngot;
TileIronPlate tilePlate;
Random rand;
private ItemStack stackGive;
public ForgeHammer() {
setMaxStackSize(1);
setUnlocalizedName(name);
setCreativeTab(CustomTab.MedievalCraftTab);
setTextureName(Main.MODID + ":" + name);
setMaxDamage(500);
setNoRepair();
item = this;
GameRegistry.registerItem(this, name);
}
private Block blockToRun(Block block) {
if(block == TestForgeCrafting.blockToCook.get(0)){
blockKey = 0;
return TestForgeCrafting.blockToCook.get(0);
} else
if(block == TestForgeCrafting.blockToCook.get(3)){
blockKey = 3;
return TestForgeCrafting.blockToCook.get(3);
} else
if(block == TestForgeCrafting.blockToCook.get(6)){
blockKey = 6;
return TestForgeCrafting.blockToCook.get(6);
} else return block = Blocks.air;
}
private void onClick(Block block, Block blockSub, World world, int x, int y, int z, EntityPlayer p, ItemStack stack, Random rand){
//System.out.println("Layer 1");
if(block == ModBlocks.refinedIron){
tileRefIngot = (TileMyIronIngot) world.getTileEntity(x, y, z);
}
if(block == ModBlocks.ironPlate){
tilePlate = (TileIronPlate) world.getTileEntity(x, y, z);
}
if((blockSub == ModBlocks.forgeAnvil)&&(p.isSwingInProgress == false)){
TileEntityAnvilForge tileEnt = (TileEntityAnvilForge) world.getTileEntity(x, y-1, z);
if((block instanceof IngotBase)&&(block==ModBlocks.refinedIron)){
TileIngotBase tile = (TileIngotBase) world.getTileEntity(x, y, z);
if(tileEnt.getStackInSlot(0)==null){
p.worldObj.playSoundAtEntity(p, Main.MODID + ":anvilhammer", 1.0F, 1.0F);
Main.sNet.sendToAll(new MsgPacket(true));
Main.sNet.sendToAll(new MsgPacketLocX(x));
Main.sNet.sendToAll(new MsgPacketLocY(y));
Main.sNet.sendToAll(new MsgPacketLocZ(z));
tile.hits++;
stack.damageItem(1, p);
if(tile.hits >= 4 + rand.nextInt(3)){
world.setBlock(x, y, z, ModBlocks.ironPlate, 0, 2);
}
}
if(tileEnt.getStackInSlot(0)!=null){
if((tileEnt.getStackInSlot(0).getItem().equals(Items.flower_pot))||tileEnt.getStackInSlot(0).getItem().equals(Items.bucket)){
p.worldObj.playSoundAtEntity(p, Main.MODID + ":anvilhammer", 1.0F, 1.0F);
Main.sNet.sendToAll(new MsgPacket(true));
Main.sNet.sendToAll(new MsgPacketLocX(x));
Main.sNet.sendToAll(new MsgPacketLocY(y));
Main.sNet.sendToAll(new MsgPacketLocZ(z));
tile.hits++;
stack.damageItem(1, p);
if(tile.hits >= 4 + rand.nextInt(3)){
world.setBlock(x, y, z, Blocks.air, 0, 2);
if(tileEnt.getStackInSlot(0).getItem().equals(Items.flower_pot)){
tileEnt.decrStackSize(0, 1);
}
world.spawnEntityInWorld(new EntityItem(world, x+0.5D, y+0.6D, z+0.5D, new ItemStack(Items.bucket, 1)));
}
}
//IRON FORMS
if(tileEnt.getStackInSlot(0)!=null){
if((tileEnt.getStackInSlot(0).getItem() instanceof IronForms)&&(tile.hot==true)){
//System.out.println("working");
p.worldObj.playSoundAtEntity(p, Main.MODID + ":anvilhammer", 1.0F, 1.0F);
Main.sNet.sendToAll(new MsgPacket(true));
Main.sNet.sendToAll(new MsgPacketLocX(x));
Main.sNet.sendToAll(new MsgPacketLocY(y));
Main.sNet.sendToAll(new MsgPacketLocZ(z));
tile.hits++;
stack.damageItem(1, p);
if(tile.hits >= 4 + rand.nextInt(3)){
Item itemGive = formsIronTest.get(tileEnt.getStackInSlot(0).getItem());
if(itemGive == ModItems.irondaggerBlade){
stackGive = new ItemStack (itemGive, 3);
} else if (itemGive == ModItems.ironweaponHandle){
stackGive = new ItemStack (itemGive, 2);
} else if (itemGive == ModItems.ironRing){
stackGive = new ItemStack (itemGive, 9);
} else if (itemGive == ModItems.ironsharpTip){
stackGive = new ItemStack (itemGive, 9);
} else if (itemGive == ModItems.ironshortswordBlade){
stackGive = new ItemStack (itemGive, 2);
} else {
stackGive = new ItemStack (itemGive, 1);
}
System.out.println(stackGive);
world.spawnEntityInWorld(new EntityItem(world, x+0.5D, y+0.6D, z+0.5D, stackGive));
//formsIron.get(tileEnt.getStackInSlot(0).getItem())
System.out.println(formsIron.get(tileEnt.getStackInSlot(0).getItem()));
world.setBlock(x, y, z, Blocks.air, 0, 2);
if(tileEnt.getStackInSlot(0).getMaxStackSize() == 1){
if(tileEnt.getStackInSlot(0).getItemDamage() == tileEnt.getStackInSlot(0).getMaxDamage()-1){
tileEnt.decrStackSize(0, 1);
}
else {tileEnt.getStackInSlot(0).setItemDamage(tileEnt.getStackInSlot(0).getItemDamage()+1);
}
}
}
}
//CLAY FORMS
if((tileEnt.getStackInSlot(0).getItem() instanceof ClayForms)&&(tile.hot==true)){
p.worldObj.playSoundAtEntity(p, Main.MODID + ":anvilhammer", 1.0F, 1.0F);
Main.sNet.sendToAll(new MsgPacket(true));
Main.sNet.sendToAll(new MsgPacketLocX(x));
Main.sNet.sendToAll(new MsgPacketLocY(y));
Main.sNet.sendToAll(new MsgPacketLocZ(z));
tile.hits++;
stack.damageItem(1, p);
if(tile.hits >= 4 + rand.nextInt(3)){
world.spawnEntityInWorld(new EntityItem(world, x+0.5D, y+0.6D, z+0.5D, formsClay.get(tileEnt.getStackInSlot(0).getItem())));
world.setBlock(x, y, z, Blocks.air, 0, 2);
tileEnt.decrStackSize(0, 1);
tile.markForUpdate();
}
}
}
}
if((block instanceof IngotBase)){
//TileIngotBase tile = (TileIngotBase) world.getTileEntity(x, y, z);
//REPAIR TOOLS
if(tileEnt.getStackInSlot(0) != null){
Item checkItem = tileEnt.getStackInSlot(0).getItem();
String displayName = tileEnt.getStackInSlot(0).getDisplayName();
if(displayName.equals(getTool(tileEnt.getStackInSlot(0)))&&(tile.hot == true)&&(block==ModBlocks.refinedIron)){
if(tileEnt.getStackInSlot(0).isItemDamaged() == true){
p.worldObj.playSoundAtEntity(p, Main.MODID + ":anvilhammer", 1.0F, 1.0F);
Main.sNet.sendToAll(new MsgPacket(true));
Main.sNet.sendToAll(new MsgPacketLocX(x));
Main.sNet.sendToAll(new MsgPacketLocY(y));
Main.sNet.sendToAll(new MsgPacketLocZ(z));
stack.damageItem(1, p);
tile.hits++;
if(tile.hits >= 4 + rand.nextInt(3)){
checkItem.setDamage(tileEnt.getStackInSlot(0), 0);
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
}
}
}
}
//MAKE FORMS
if((block instanceof IngotBase)&&(block==ModBlocks.ironPlate)){
TileIngotBase tile = (TileIngotBase) world.getTileEntity(x, y, z);
if(tileEnt.getStackInSlot(0)!= null){
if((makeForms.containsKey(tileEnt.getStackInSlot(0).getItem())==true)){
if((tile.hot == true)&&(block==ModBlocks.ironPlate)){
p.worldObj.playSoundAtEntity(p, Main.MODID + ":anvilhammer", 1.0F, 1.0F);
Main.sNet.sendToAll(new MsgPacket(true));
Main.sNet.sendToAll(new MsgPacketLocX(x));
Main.sNet.sendToAll(new MsgPacketLocY(y));
Main.sNet.sendToAll(new MsgPacketLocZ(z));
stack.damageItem(1, p);
tile.hits++;
if(tile.hits >= 4 + rand.nextInt(3)){
world.spawnEntityInWorld(new EntityItem(world, x+0.5D, y+0.6D, z+0.5D, makeForms.get(tileEnt.getStackInSlot(0).getItem())));
world.setBlock(x, y, z, Blocks.air, 0, 2);
tileEnt.decrStackSize(0, 1);
tile.markForUpdate();
}
}
}
}
}
}
}
/*
* ItemStack gladius0 = new ItemStack(ModItems.gladius);
gladius0.stackTagCompound = new NBTTagCompound();
gladius0.stackTagCompound.setInteger("GLADIUSTEXTURE", 0);
*/
public void giveItem(int a, World world, int x, int y, int z, EntityPlayer p){
if(blockKey == 0){
world.setBlock(x, y, z, Blocks.air, 0, 2);
p.worldObj.playSoundAtEntity(p, Main.MODID + ":anvilhammer", 1.0F, 1.0F);
world.spawnEntityInWorld(new EntityItem(world, x+0.5D, y+0.6D, z+0.5D, ForgeAnvilCrafting.itemToGive.get(key)));
}
if(blockKey == 3){
Item item = ForgeAnvilCrafting.itemToCheck.get(key);
world.setBlock(x, y, z, Blocks.air, 0, 2);
p.worldObj.playSoundAtEntity(p, Main.MODID + ":anvilhammer", 1.0F, 1.0F);
world.spawnEntityInWorld(new EntityItem(world, x+0.5D, y+0.6D, z+0.5D, new ItemStack(item, 1, 0)));
}
}
private Item getItem(Item testItem){
for(int i = 0; i < ForgeAnvilCrafting.itemToCheck.size(); i++){
if(testItem == ForgeAnvilCrafting.itemToCheck.get(i)){
key = i;
}
}
return ForgeAnvilCrafting.itemToCheck.get(key);
}
private ItemStack getItem2(Item testItem){
for(int i = 0; i < ForgeAnvilCrafting.itemToGive.size(); i++){
if(testItem == ForgeAnvilCrafting.itemToGive.get(i).getItem()){
key = i;
}
}
return ForgeAnvilCrafting.itemToGive.get(key);
}
private Item getItem3(Item testItem){
for(int i = 0; i < ForgeAnvilCrafting.itemToCheckClay.size(); i++){
if(testItem == ForgeAnvilCrafting.itemToCheckClay.get(i)){
key = i;
}
}
return ForgeAnvilCrafting.itemToCheckClay.get(key);
}
private String getTool(ItemStack s){
for(int i = 0; i < ForgeAnvilCrafting.toolToRepair.size(); i++){
if(s.getDisplayName().equals(ForgeAnvilCrafting.toolToRepair.get(i)) ){
keys = i;
}
}
return ForgeAnvilCrafting.toolToRepair.get(keys);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_){
Block block = world.getBlock(x, y, z);
Block anvil = world.getBlock(x, y-1, z);
if(!world.isRemote){
onClick(block, anvil, world, x, y, z, player, stack, world.rand);
}
return true;
}
@Override
public void onUpdate(ItemStack stack, World world, Entity player, int p_77663_4_, boolean using) {
if(using == true){
((EntityLivingBase) player).addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 10, 4, true));
}
}
@Override
public int getItemEnchantability () {
return 0;
}
@Override
public boolean getIsRepairable(ItemStack item, ItemStack repair)
{
return Items.iron_ingot == repair.getItem() ? true : false;
}
@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemstack) {
return false;
}
@Override
public Item getContainerItem()
{
item.setDamage(new ItemStack(item), +1);
return item;
}
}

Some files were not shown because too many files have changed in this diff Show More