From 650f9b5a679afd3bfed3a7cd112d2390ea7415a3 Mon Sep 17 00:00:00 2001 From: Tschipp Date: Wed, 24 Jan 2018 16:30:37 +0100 Subject: [PATCH 1/4] McMod --- src/main/resources/mcmod.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 6790c2d..4bfb19f 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -2,7 +2,7 @@ { "modid" : "carryon", "name" : "Carry On", - "version" : "1.7", "mcversion" : "1.11.2", + "version" : "1.7.1", "mcversion" : "1.11.2", "url" : "", "credits" : "Tschipp, Purplicious_Cow, cy4n", "authorList" : ["Tschipp, Purplicious_Cow, cy4n"], From fe802ea04aea884b098eec44fc1df6d120e78a07 Mon Sep 17 00:00:00 2001 From: Purplicious_Cow Date: Fri, 16 Feb 2018 07:42:54 +0100 Subject: [PATCH 2/4] Create LICENSE --- LICENSE | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. From 3f444ac5f8c25fc5e35a40ecf934c5b45587cff6 Mon Sep 17 00:00:00 2001 From: The_Fireplace Date: Sat, 17 Feb 2018 17:40:28 -0600 Subject: [PATCH 3/4] Added en_UD.lang --- src/main/resources/assets/carryon/lang/en_UD.lang | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/resources/assets/carryon/lang/en_UD.lang diff --git a/src/main/resources/assets/carryon/lang/en_UD.lang b/src/main/resources/assets/carryon/lang/en_UD.lang new file mode 100644 index 0000000..9c3ef24 --- /dev/null +++ b/src/main/resources/assets/carryon/lang/en_UD.lang @@ -0,0 +1,14 @@ +carryon.category.settings=sᵷuᴉʇʇǝS +carryon.category.blacklist=ʇsᴉꞁʞɔɐꞁᗺ +carryon.category.modeloverrides=(pǝɔuɐʌpⱯ) sǝpᴉɹɹǝʌO ꞁǝpoW +carryon.category.custompickupconditions=(pǝɔuɐʌpⱯ) suoᴉʇᴉpuoƆ dnʞɔᴉԀ ɯoʇsnƆ +carryon.category.whitelist=ʇsᴉꞁǝʇᴉɥM + +carryon.general.modeloverrides.modeloverrides=sǝpᴉɹɹǝʌO ꞁǝpoW +carryon.general.blacklist.forbiddenentities=dn ʞɔᴉd ʇouuɐɔ ɹǝʎɐꞁԀ ǝɥʇ ʇɐɥʇ sǝᴉʇᴉʇuƎ +carryon.general.blacklist.forbiddentiles=dn ʞɔᴉd ʇouuɐɔ ɹǝʎɐꞁԀ ǝɥʇ ʇɐɥʇ sʞɔoꞁᗺ +carryon.category.custompickupconditions.custompickupconditionsblocks=suoᴉʇᴉpuoƆ dnʞɔᴉԀ ʞɔoꞁᗺ ɯoʇsnƆ +carryon.category.custompickupconditions.custompickupconditionsentities=suoᴉʇᴉpuoƆ dnʞɔᴉԀ ʎʇᴉʇuƎ ɯoʇsnƆ + +key.carry.desc=ʎɹɹɐƆ +key.carry.category=uO ʎɹɹɐƆ From 90fe9544a0fd228937ee4848529725d5913366f5 Mon Sep 17 00:00:00 2001 From: Tschipp Date: Sat, 24 Mar 2018 11:02:20 +0100 Subject: [PATCH 4/4] Different Fixes, 1.11 --- src/main/java/tschipp/carryon/CarryOn.java | 2 +- .../client/event/RenderEntityEvents.java | 12 ++- .../carryon/client/event/RenderEvents.java | 15 ++- .../client/model/ModelPlayerCarrying.java | 23 +++++ .../tschipp/carryon/common/CommonProxy.java | 1 + .../common/capabilities/IPosition.java | 16 ++++ .../common/capabilities/PositionProvider.java | 37 ++++++++ .../common/capabilities/PositionStorage.java | 41 +++++++++ .../common/capabilities/TEPosition.java | 34 +++++++ .../event/PositionClientEvents.java | 91 +++++++++++++++++++ .../event/PositionCommonEvents.java | 60 ++++++++++++ .../carryon/common/config/Configs.java | 9 ++ .../common/event/ItemEntityEvents.java | 6 +- .../carryon/common/event/ItemEvents.java | 1 + .../common/handler/RegistrationHandler.java | 13 ++- .../tschipp/carryon/common/item/ItemTile.java | 2 +- src/main/resources/mcmod.info | 2 +- 17 files changed, 348 insertions(+), 17 deletions(-) create mode 100644 src/main/java/tschipp/carryon/client/model/ModelPlayerCarrying.java create mode 100644 src/main/java/tschipp/carryon/common/capabilities/IPosition.java create mode 100644 src/main/java/tschipp/carryon/common/capabilities/PositionProvider.java create mode 100644 src/main/java/tschipp/carryon/common/capabilities/PositionStorage.java create mode 100644 src/main/java/tschipp/carryon/common/capabilities/TEPosition.java create mode 100644 src/main/java/tschipp/carryon/common/capabilities/event/PositionClientEvents.java create mode 100644 src/main/java/tschipp/carryon/common/capabilities/event/PositionCommonEvents.java diff --git a/src/main/java/tschipp/carryon/CarryOn.java b/src/main/java/tschipp/carryon/CarryOn.java index 9b935c3..e92cfda 100644 --- a/src/main/java/tschipp/carryon/CarryOn.java +++ b/src/main/java/tschipp/carryon/CarryOn.java @@ -34,7 +34,7 @@ public class CarryOn { public static CarryOn instance; public static final String MODID = "carryon"; - public static final String VERSION = "1.7.1"; + public static final String VERSION = "1.8"; public static final String NAME = "Carry On"; public static final String ACCEPTED_VERSIONS = "[1.11,1.12)"; public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/"; diff --git a/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java b/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java index b8397b8..1ab616a 100644 --- a/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java +++ b/src/main/java/tschipp/carryon/client/event/RenderEntityEvents.java @@ -25,6 +25,7 @@ import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderPlayerEvent; +import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; @@ -33,6 +34,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import tschipp.carryon.common.handler.RegistrationHandler; import tschipp.carryon.common.helper.ScriptParseHelper; import tschipp.carryon.common.item.ItemEntity; +import tschipp.carryon.common.item.ItemTile; import tschipp.carryon.common.scripting.CarryOnOverride; import tschipp.carryon.common.scripting.ScriptChecker; @@ -64,21 +66,23 @@ public class RenderEntityEvents */ @SideOnly(Side.CLIENT) @SubscribeEvent - public void onGuiOpen(GuiOpenEvent event) + public void onGuiInit(InitGuiEvent.Pre event) { if (event.getGui() != null) { boolean inventory = event.getGui() instanceof GuiContainer; EntityPlayer player = Minecraft.getMinecraft().player; - if (player != null) + if (player != null && inventory) { ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND); - if (inventory && !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack)) + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack)) { - event.setCanceled(true); + Minecraft.getMinecraft().player.closeScreen(); Minecraft.getMinecraft().currentScreen = null; + Minecraft.getMinecraft().setIngameFocus(); + } } } diff --git a/src/main/java/tschipp/carryon/client/event/RenderEvents.java b/src/main/java/tschipp/carryon/client/event/RenderEvents.java index e4e7438..f8f19a2 100644 --- a/src/main/java/tschipp/carryon/client/event/RenderEvents.java +++ b/src/main/java/tschipp/carryon/client/event/RenderEvents.java @@ -16,7 +16,6 @@ import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.settings.GameSettings; @@ -31,13 +30,11 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderPlayerEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; @@ -115,21 +112,23 @@ public class RenderEvents */ @SideOnly(Side.CLIENT) @SubscribeEvent - public void onGuiOpen(GuiOpenEvent event) + public void onGuiInit(InitGuiEvent.Pre event) { if (event.getGui() != null) { boolean inventory = event.getGui() instanceof GuiContainer; EntityPlayer player = Minecraft.getMinecraft().player; - if (player != null) + if (player != null && inventory) { ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND); - if (inventory && !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) + if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) { - event.setCanceled(true); + Minecraft.getMinecraft().player.closeScreen(); Minecraft.getMinecraft().currentScreen = null; + Minecraft.getMinecraft().setIngameFocus(); + } } } diff --git a/src/main/java/tschipp/carryon/client/model/ModelPlayerCarrying.java b/src/main/java/tschipp/carryon/client/model/ModelPlayerCarrying.java new file mode 100644 index 0000000..956366f --- /dev/null +++ b/src/main/java/tschipp/carryon/client/model/ModelPlayerCarrying.java @@ -0,0 +1,23 @@ +package tschipp.carryon.client.model; + +import net.minecraft.client.model.ModelPlayer; +import net.minecraft.entity.Entity; + +public class ModelPlayerCarrying extends ModelPlayer +{ + + public ModelPlayerCarrying(float modelSize, boolean smallArmsIn) + { + super(modelSize, smallArmsIn); + } + + @Override + public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) + { + super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); + + + + } + +} diff --git a/src/main/java/tschipp/carryon/common/CommonProxy.java b/src/main/java/tschipp/carryon/common/CommonProxy.java index 5740705..123c13b 100644 --- a/src/main/java/tschipp/carryon/common/CommonProxy.java +++ b/src/main/java/tschipp/carryon/common/CommonProxy.java @@ -52,6 +52,7 @@ public class CommonProxy e.printStackTrace(); } RegistrationHandler.regOverrideList(); + RegistrationHandler.regCaps(); } @EventHandler diff --git a/src/main/java/tschipp/carryon/common/capabilities/IPosition.java b/src/main/java/tschipp/carryon/common/capabilities/IPosition.java new file mode 100644 index 0000000..35d90e2 --- /dev/null +++ b/src/main/java/tschipp/carryon/common/capabilities/IPosition.java @@ -0,0 +1,16 @@ +package tschipp.carryon.common.capabilities; + +import net.minecraft.util.math.BlockPos; + +public interface IPosition { + + public BlockPos getPos(); + + public void setPos(BlockPos pos); + + public boolean isBlockActivated(); + + public void setBlockActivated(boolean b); + + +} diff --git a/src/main/java/tschipp/carryon/common/capabilities/PositionProvider.java b/src/main/java/tschipp/carryon/common/capabilities/PositionProvider.java new file mode 100644 index 0000000..6f46a79 --- /dev/null +++ b/src/main/java/tschipp/carryon/common/capabilities/PositionProvider.java @@ -0,0 +1,37 @@ +package tschipp.carryon.common.capabilities; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; +import net.minecraftforge.common.capabilities.ICapabilitySerializable; + +public class PositionProvider implements ICapabilitySerializable { + + @CapabilityInject(IPosition.class) + public static final Capability POSITION_CAPABILITY = null; + + private IPosition instance = POSITION_CAPABILITY.getDefaultInstance(); + + + @Override + public boolean hasCapability(Capability capability, EnumFacing facing) { + return capability == POSITION_CAPABILITY; + } + + @Override + public T getCapability(Capability capability, EnumFacing facing) { + return capability == POSITION_CAPABILITY ? POSITION_CAPABILITY.cast(instance) : null; + } + + @Override + public NBTBase serializeNBT() { + return POSITION_CAPABILITY.getStorage().writeNBT(POSITION_CAPABILITY, instance, null); + } + + @Override + public void deserializeNBT(NBTBase nbt) { + POSITION_CAPABILITY.getStorage().readNBT(POSITION_CAPABILITY, instance, null, nbt); + } + +} diff --git a/src/main/java/tschipp/carryon/common/capabilities/PositionStorage.java b/src/main/java/tschipp/carryon/common/capabilities/PositionStorage.java new file mode 100644 index 0000000..d3a4973 --- /dev/null +++ b/src/main/java/tschipp/carryon/common/capabilities/PositionStorage.java @@ -0,0 +1,41 @@ +package tschipp.carryon.common.capabilities; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.Capability.IStorage; + +public class PositionStorage implements IStorage { + + @Override + public NBTBase writeNBT(Capability capability, IPosition instance, EnumFacing side) { + + NBTTagCompound tag = new NBTTagCompound(); + + tag.setBoolean("blockActivated", instance.isBlockActivated()); + tag.setInteger("x", instance.getPos().getX()); + tag.setInteger("y", instance.getPos().getY()); + tag.setInteger("z", instance.getPos().getZ()); + + return tag; + + } + + @Override + public void readNBT(Capability capability, IPosition instance, EnumFacing side, NBTBase nbt) { + + NBTTagCompound tag = (NBTTagCompound) nbt; + + int x = tag.getInteger("x"); + int y = tag.getInteger("y"); + int z = tag.getInteger("z"); + + BlockPos pos = new BlockPos(x,y,z); + + instance.setPos(pos); + instance.setBlockActivated(tag.getBoolean("blockActivated")); + } + +} diff --git a/src/main/java/tschipp/carryon/common/capabilities/TEPosition.java b/src/main/java/tschipp/carryon/common/capabilities/TEPosition.java new file mode 100644 index 0000000..7398fc0 --- /dev/null +++ b/src/main/java/tschipp/carryon/common/capabilities/TEPosition.java @@ -0,0 +1,34 @@ +package tschipp.carryon.common.capabilities; + +import net.minecraft.util.math.BlockPos; + +public class TEPosition implements IPosition { + + private BlockPos pos = new BlockPos(0, 0, 0); + private boolean blockActivated = false; + + @Override + public BlockPos getPos() + { + return pos; + } + @Override + public void setPos(BlockPos pos) + { + this.pos = pos; + } + @Override + public boolean isBlockActivated() + { + return blockActivated; + } + @Override + public void setBlockActivated(boolean b) + { + this.blockActivated = b; + } + + + + +} diff --git a/src/main/java/tschipp/carryon/common/capabilities/event/PositionClientEvents.java b/src/main/java/tschipp/carryon/common/capabilities/event/PositionClientEvents.java new file mode 100644 index 0000000..1d6e3e8 --- /dev/null +++ b/src/main/java/tschipp/carryon/common/capabilities/event/PositionClientEvents.java @@ -0,0 +1,91 @@ +package tschipp.carryon.common.capabilities.event; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.event.entity.player.PlayerContainerEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import tschipp.carryon.common.capabilities.IPosition; +import tschipp.carryon.common.capabilities.PositionProvider; + +public class PositionClientEvents +{ + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onGui(GuiScreenEvent.DrawScreenEvent event) + { + if (event.getGui() != null) + { + EntityPlayer player = Minecraft.getMinecraft().player; + boolean inventory = event.getGui() instanceof GuiContainer; + + if (player != null && inventory) + { + if(player.hasCapability(PositionProvider.POSITION_CAPABILITY, null)) + { + IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null); + if(cap.isBlockActivated()) + { + World world = player.world; + BlockPos pos = cap.getPos(); + if(world != null) + { + TileEntity te = world.getTileEntity(pos); + if(te == null) + { +// player.openContainer = null; + Minecraft.getMinecraft().currentScreen = null; + Minecraft.getMinecraft().setIngameFocus(); + cap.setBlockActivated(false); + cap.setPos(new BlockPos(0,0,0)); + } + } + } + } + } + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onGuiClose(PlayerContainerEvent.Close event) + { + EntityPlayer player = event.getEntityPlayer(); + if(player.hasCapability(PositionProvider.POSITION_CAPABILITY, null)) + { + IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null); + cap.setBlockActivated(false); + cap.setPos(new BlockPos(0,0,0)); + } + } + + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onPlayerTick(PlayerTickEvent event) + { + if (event.side == Side.CLIENT) + { + EntityPlayer player = event.player; + if (player.hasCapability(PositionProvider.POSITION_CAPABILITY, null)) + { + IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null); + if (cap.isBlockActivated() && Minecraft.getMinecraft().currentScreen == null) + { + cap.setBlockActivated(false); + cap.setPos(new BlockPos(0, 0, 0)); + } + } + } + } + + +} diff --git a/src/main/java/tschipp/carryon/common/capabilities/event/PositionCommonEvents.java b/src/main/java/tschipp/carryon/common/capabilities/event/PositionCommonEvents.java new file mode 100644 index 0000000..ae25abd --- /dev/null +++ b/src/main/java/tschipp/carryon/common/capabilities/event/PositionCommonEvents.java @@ -0,0 +1,60 @@ +package tschipp.carryon.common.capabilities.event; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.event.AttachCapabilitiesEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import tschipp.carryon.CarryOn; +import tschipp.carryon.common.capabilities.IPosition; +import tschipp.carryon.common.capabilities.PositionProvider; + +public class PositionCommonEvents +{ + + @SubscribeEvent + public void onAttachCaps(AttachCapabilitiesEvent event) + { + if (event.getObject() instanceof EntityPlayer) + { + event.addCapability(new ResourceLocation(CarryOn.MODID, "position"), new PositionProvider()); + } + + } + + @SubscribeEvent + public void onBlockRight(PlayerInteractEvent.RightClickBlock event) + { + BlockPos pos = event.getPos(); + World world = event.getWorld(); + EntityPlayer player = event.getEntityPlayer(); + + if (event.isCanceled()) + return; + + if (player == null) + return; + + if (player instanceof FakePlayer) + return; + + TileEntity te = world.getTileEntity(pos); + if (te != null) + { + if (player.hasCapability(PositionProvider.POSITION_CAPABILITY, null)) + { + IPosition cap = player.getCapability(PositionProvider.POSITION_CAPABILITY, null); + cap.setBlockActivated(true); + cap.setPos(pos); + } + } + } + + + +} diff --git a/src/main/java/tschipp/carryon/common/config/Configs.java b/src/main/java/tschipp/carryon/common/config/Configs.java index c028518..911017e 100644 --- a/src/main/java/tschipp/carryon/common/config/Configs.java +++ b/src/main/java/tschipp/carryon/common/config/Configs.java @@ -123,6 +123,10 @@ public class Configs { "embers:field_chart", "embers:inferno_forge", "storagedrawers:framingtable", + "skyresources:*", + "lootbags:*", + "exsartagine:*", + }; @Config.RequiresMcRestart() @@ -133,6 +137,11 @@ public class Configs { "minecraft:ender_dragon", "minecraft:ghast", "minecraft:shulker", + "minecraft:leash_knot", + "minecraft:armor_stand", + "minecraft:item_frame", + "minecraft:painting", + "minecraft:shulker_bullet", "animania:textures/entity/pigs/hamster_tarou.png", "animania:hamster", "animania:ferret*", diff --git a/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java b/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java index 830f017..1cc5df2 100644 --- a/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java +++ b/src/main/java/tschipp/carryon/common/event/ItemEntityEvents.java @@ -4,6 +4,7 @@ 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.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; @@ -16,9 +17,9 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.Event.Result; -import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import tschipp.carryon.CarryOn; @@ -88,6 +89,9 @@ public class ItemEntityEvents if (entity.hurtResistantTime == 0) { + if(entity instanceof EntityAnimal) + ((EntityAnimal) entity).clearLeashed(true, true); + if (PickupHandler.canPlayerPickUpEntity(player, entity)) { if (ItemEntity.storeEntityData(entity, world, stack)) diff --git a/src/main/java/tschipp/carryon/common/event/ItemEvents.java b/src/main/java/tschipp/carryon/common/event/ItemEvents.java index 40d26e5..f5f7b97 100644 --- a/src/main/java/tschipp/carryon/common/event/ItemEvents.java +++ b/src/main/java/tschipp/carryon/common/event/ItemEvents.java @@ -218,6 +218,7 @@ public class ItemEvents { player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY); EntityItem item = new EntityItem(player.world, player.posX, player.posY, player.posZ, stack); + CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(player.world.provider.getDimension(), player.posX, player.posY, player.posZ, 256)); player.world.spawnEntity(item); } } diff --git a/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java b/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java index 8b0ec33..35fa825 100644 --- a/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java +++ b/src/main/java/tschipp/carryon/common/handler/RegistrationHandler.java @@ -4,9 +4,15 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.capabilities.CapabilityManager; import tschipp.carryon.CarryOn; import tschipp.carryon.client.event.RenderEntityEvents; import tschipp.carryon.client.event.RenderEvents; +import tschipp.carryon.common.capabilities.IPosition; +import tschipp.carryon.common.capabilities.PositionStorage; +import tschipp.carryon.common.capabilities.TEPosition; +import tschipp.carryon.common.capabilities.event.PositionClientEvents; +import tschipp.carryon.common.capabilities.event.PositionCommonEvents; import tschipp.carryon.common.event.ItemEntityEvents; import tschipp.carryon.common.event.ItemEvents; import tschipp.carryon.common.item.ItemEntity; @@ -33,12 +39,14 @@ public class RegistrationHandler { MinecraftForge.EVENT_BUS.register(new ItemEvents()); MinecraftForge.EVENT_BUS.register(new ItemEntityEvents()); + MinecraftForge.EVENT_BUS.register(new PositionCommonEvents()); } public static void regClientEvents() { MinecraftForge.EVENT_BUS.register(new RenderEvents()); MinecraftForge.EVENT_BUS.register(new RenderEntityEvents()); + MinecraftForge.EVENT_BUS.register(new PositionClientEvents()); } public static void regOverrideList() @@ -48,6 +56,9 @@ public class RegistrationHandler ListHandler.initForbiddenTiles(); } - + public static void regCaps() + { + CapabilityManager.INSTANCE.register(IPosition.class, new PositionStorage(), TEPosition::new); + } } diff --git a/src/main/java/tschipp/carryon/common/item/ItemTile.java b/src/main/java/tschipp/carryon/common/item/ItemTile.java index 154e437..9b26c0f 100644 --- a/src/main/java/tschipp/carryon/common/item/ItemTile.java +++ b/src/main/java/tschipp/carryon/common/item/ItemTile.java @@ -153,7 +153,7 @@ public class ItemTile extends Item { e.printStackTrace(); - if (world.isRemote) + if (world != null && world.isRemote) { CarryOn.LOGGER.info("Block: " + ItemTile.getBlock(stack)); CarryOn.LOGGER.info("BlockState: " + ItemTile.getBlockState(stack)); diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 4bfb19f..a824278 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -2,7 +2,7 @@ { "modid" : "carryon", "name" : "Carry On", - "version" : "1.7.1", "mcversion" : "1.11.2", + "version" : "1.8", "mcversion" : "1.11.2", "url" : "", "credits" : "Tschipp, Purplicious_Cow, cy4n", "authorList" : ["Tschipp, Purplicious_Cow, cy4n"],