LLibrary Support
This commit is contained in:
parent
cb5edc3061
commit
7174a92b69
|
|
@ -24,7 +24,7 @@ compileJava {
|
|||
}
|
||||
|
||||
minecraft {
|
||||
version = "1.12.2-14.23.4.2765"
|
||||
version = "1.12.2-14.23.5.2816"
|
||||
runDir = "run"
|
||||
|
||||
mappings = "snapshot_20171003"
|
||||
|
|
@ -37,6 +37,9 @@ repositories {
|
|||
|
||||
maven { url = "https://mrcrayfish.com/maven" }
|
||||
|
||||
maven {
|
||||
url "https://maven.mcmoddev.com/"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -46,6 +49,7 @@ dependencies {
|
|||
// deobfCompile "net.darkhax.gamestages:GameStages-1.12.2:2.0.91"
|
||||
|
||||
compile "com.mrcrayfish:obfuscate:0.2.6-1.12.2"
|
||||
compile "net.ilexiconn:llibrary:1.7.9-1.12.2:dev"
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import java.io.File;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
|
|
@ -15,10 +17,14 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import tschipp.carryon.common.CommonProxy;
|
||||
import tschipp.carryon.common.command.CommandCarryOn;
|
||||
import tschipp.carryon.common.command.CommandCarryOnReload;
|
||||
import tschipp.carryon.common.handler.ListHandler;
|
||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||
|
||||
@EventBusSubscriber
|
||||
@Mod(modid = CarryOn.MODID, name = CarryOn.NAME, version = CarryOn.VERSION, guiFactory = "tschipp.carryon.client.gui.GuiFactoryCarryOn", dependencies = CarryOn.DEPENDENCIES, updateJSON = CarryOn.UPDATE_JSON, acceptedMinecraftVersions = CarryOn.ACCEPTED_VERSIONS, certificateFingerprint = CarryOn.CERTIFICATE_FINGERPRINT)
|
||||
|
|
@ -32,7 +38,7 @@ public class CarryOn {
|
|||
public static CarryOn instance;
|
||||
|
||||
public static final String MODID = "carryon";
|
||||
public static final String VERSION = "1.12";
|
||||
public static final String VERSION = "1.12.2";
|
||||
public static final String NAME = "Carry On";
|
||||
public static final String ACCEPTED_VERSIONS = "[1.12.2,1.13)";
|
||||
public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/";
|
||||
|
|
@ -41,6 +47,8 @@ public class CarryOn {
|
|||
public static final String CERTIFICATE_FINGERPRINT = "55e88f24d04398481ae6f1ce76f65fd776f14227";
|
||||
public static File CONFIGURATION_FILE;
|
||||
|
||||
public static boolean FINGERPRINT_VIOLATED = false;
|
||||
|
||||
public static SimpleNetworkWrapper network;
|
||||
|
||||
@EventHandler
|
||||
|
|
@ -69,6 +77,46 @@ public class CarryOn {
|
|||
public void onFingerprintViolation(FMLFingerprintViolationEvent event) {
|
||||
|
||||
LOGGER.error("WARNING! Invalid fingerprint detected! The file " + event.getSource().getName() + " may have been tampered with! If you didn't download the file from https://minecraft.curseforge.com/projects/carry-on or through any kind of mod launcher, immediately delete the file and re-download it from https://minecraft.curseforge.com/projects/carry-on");
|
||||
}
|
||||
FINGERPRINT_VIOLATED = true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void imcEvent(IMCEvent event)
|
||||
{
|
||||
ImmutableList<IMCMessage> messages = event.getMessages();
|
||||
|
||||
messages.forEach((msg) -> {
|
||||
|
||||
String method = msg.key;
|
||||
String str = msg.getStringValue();
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case "blacklistBlock":
|
||||
ListHandler.FORBIDDEN_TILES.add(str);
|
||||
break;
|
||||
case "blacklistEntity":
|
||||
ListHandler.FORBIDDEN_ENTITIES.add(str);
|
||||
break;
|
||||
case "whitelistBlock":
|
||||
ListHandler.ALLOWED_TILES.add(str);
|
||||
break;
|
||||
case "whitelistEntity":
|
||||
ListHandler.ALLOWED_ENTITIES.add(str);
|
||||
break;
|
||||
case "blacklistStacking":
|
||||
ListHandler.FORBIDDEN_STACKING.add(str);
|
||||
break;
|
||||
case "whitelistStacking":
|
||||
ListHandler.ALLOWED_STACKING.add(str);
|
||||
break;
|
||||
case "addModelOverride":
|
||||
ModelOverridesHandler.parseOverride(str, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import net.minecraft.client.settings.GameSettings;
|
|||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
|
@ -22,11 +23,10 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
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.GuiScreenEvent.InitGuiEvent;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
|
|
@ -35,7 +35,6 @@ 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;
|
||||
|
||||
|
|
@ -160,7 +159,7 @@ public class RenderEntityEvents
|
|||
entity.rotationYaw = 0.0f;
|
||||
entity.prevRotationYaw = 0.0f;
|
||||
entity.setRotationYawHead(0.0f);
|
||||
|
||||
|
||||
float height = entity.height;
|
||||
float width = entity.width;
|
||||
GlStateManager.pushMatrix();
|
||||
|
|
@ -205,6 +204,9 @@ public class RenderEntityEvents
|
|||
|
||||
}
|
||||
|
||||
if(entity instanceof EntityLiving)
|
||||
((EntityLiving) entity).hurtTime = 0;
|
||||
|
||||
this.renderEntityStatic(entity);
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
|
||||
}
|
||||
|
|
@ -385,6 +387,9 @@ public class RenderEntityEvents
|
|||
|
||||
}
|
||||
|
||||
if(entity instanceof EntityLiving)
|
||||
((EntityLiving) entity).hurtTime = 0;
|
||||
|
||||
Minecraft.getMinecraft().getRenderManager().renderEntityStatic(entity, 0.0f, false);
|
||||
Minecraft.getMinecraft().getRenderManager().setRenderShadow(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ 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.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.ClickEvent.Action;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
|
|
@ -116,7 +120,16 @@ public class RenderEvents
|
|||
{
|
||||
CarryOnKeybinds.setKeyPressed(player, false);
|
||||
CarryOn.network.sendToServer(new SyncKeybindPacket(false));
|
||||
|
||||
if(CarryOn.FINGERPRINT_VIOLATED)
|
||||
{
|
||||
TextComponentString cf = new TextComponentString(TextFormatting.AQUA + "Curseforge" + TextFormatting.RED);
|
||||
cf.getStyle().setClickEvent(new ClickEvent(Action.OPEN_URL, "https://minecraft.curseforge.com/projects/carry-on"));
|
||||
|
||||
player.sendMessage(new TextComponentString(TextFormatting.RED + "[CarryOn] WARNING! Invalid fingerprint detected! The Carry On mod file may have been tampered with! If you didn't download the file from ").appendSibling(cf).appendText(TextFormatting.RED + " or through any kind of mod launcher, immediately delete the file and re-download it from ").appendSibling(cf));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -450,7 +463,7 @@ public class RenderEvents
|
|||
if(!CarryOnConfig.settings.renderArms)
|
||||
return;
|
||||
|
||||
if (handleMobends() && !Loader.isModLoaded("obfuscate"))
|
||||
if (handleMobends() && !Loader.isModLoaded("obfuscate") && !Loader.isModLoaded("llibrary"))
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
EntityPlayerSP clientPlayer = Minecraft.getMinecraft().player;
|
||||
|
|
@ -547,7 +560,7 @@ public class RenderEvents
|
|||
if(!CarryOnConfig.settings.renderArms)
|
||||
return;
|
||||
|
||||
if (handleMobends() && !Loader.isModLoaded("obfuscate"))
|
||||
if (handleMobends() && !Loader.isModLoaded("obfuscate") && !Loader.isModLoaded("llibrary"))
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
|
|
|
|||
|
|
@ -171,11 +171,21 @@ public class Configs {
|
|||
"magneticraft:hydraulic_press",
|
||||
"magneticraft:multiblock_gap",
|
||||
"refinedstorage:*",
|
||||
"practicallogistics2:*",
|
||||
"mcmultipart:*",
|
||||
"enderstorage:*",
|
||||
"betterstorage:*",
|
||||
"practicallogistics2:*"
|
||||
"practicallogistics2:*",
|
||||
"wearablebackpacks:*",
|
||||
"torcherino:*",
|
||||
"rftools:screenBlock",
|
||||
"opencomputers:*",
|
||||
"translocators:*",
|
||||
"cfm:bath_*",
|
||||
"cfm:shower_*",
|
||||
"cfm:modern_bed_*",
|
||||
"cfm:grand_chair_*",
|
||||
"cfm:fridge",
|
||||
"cfm:freezer"
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -191,7 +201,6 @@ public class Configs {
|
|||
"minecraft:item_frame",
|
||||
"minecraft:painting",
|
||||
"minecraft:shulker_bullet",
|
||||
"animania:textures/entity/pigs/hamster_tarou.png",
|
||||
"animania:hamster",
|
||||
"animania:ferret*",
|
||||
"animania:hedgehog*",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package tschipp.carryon.common.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
|
@ -265,7 +267,9 @@ public class ItemEvents
|
|||
@SubscribeEvent
|
||||
public void onWorldTick(TickEvent.WorldTickEvent event)
|
||||
{
|
||||
for (Entry<BlockPos, Integer> entry : positions.entrySet())
|
||||
Set<Entry<BlockPos, Integer>> set = new HashSet<Entry<BlockPos, Integer>>(positions.entrySet());
|
||||
|
||||
for (Entry<BlockPos, Integer> entry : set)
|
||||
{
|
||||
entry.setValue(entry.getValue() + 1);
|
||||
|
||||
|
|
@ -463,7 +467,7 @@ public class ItemEvents
|
|||
|
||||
if (hasCarried)
|
||||
{
|
||||
if (inHand.getItem() != RegistrationHandler.itemTile && inHand.getItem() != RegistrationHandler.itemEntity)
|
||||
if ((inHand.getItem() != RegistrationHandler.itemTile && inHand.getItem() != RegistrationHandler.itemEntity) && player.getPortalCooldown() == 0)
|
||||
{
|
||||
int slotBlock = getSlot(player, RegistrationHandler.itemTile);
|
||||
int slotEntity = getSlot(player, RegistrationHandler.itemEntity);
|
||||
|
|
|
|||
|
|
@ -37,122 +37,128 @@ public class ModelOverridesHandler
|
|||
|
||||
for (int i = 0; i < overrides.length; i++)
|
||||
{
|
||||
boolean errored = false;
|
||||
parseOverride(overrides[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
public static void parseOverride(String overrideStr, int i)
|
||||
{
|
||||
boolean errored = false;
|
||||
|
||||
Object toOverrideObject;
|
||||
Object overrideObject;
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
Object toOverrideObject;
|
||||
Object overrideObject;
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
String currentline = overrides[i];
|
||||
if (StringUtils.isEmpty(currentline) || !StringUtils.contains(currentline, "->"))
|
||||
new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
|
||||
String currentline = overrideStr;
|
||||
if (StringUtils.isEmpty(currentline) || !StringUtils.contains(currentline, "->"))
|
||||
new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
|
||||
|
||||
String[] sa = currentline.split("->");
|
||||
String toOverride = "";
|
||||
String override = "";
|
||||
String[] sa = currentline.split("->");
|
||||
String toOverride = "";
|
||||
String override = "";
|
||||
try
|
||||
{
|
||||
toOverride = sa[0];
|
||||
override = sa[1];
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
if (toOverride.contains("{"))
|
||||
{
|
||||
if (!toOverride.contains("}"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing } at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String nbt = toOverride.substring(toOverride.indexOf("{"));
|
||||
toOverride = toOverride.replace(nbt, "");
|
||||
try
|
||||
{
|
||||
toOverride = sa[0];
|
||||
override = sa[1];
|
||||
tag = JsonToNBT.getTagFromJson(nbt);
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e)
|
||||
catch (NBTException e)
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing Override Model at line " + i + " : " + currentline).printException();
|
||||
new InvalidConfigException("Error while parsing NBT at line " + i + " : " + e.getMessage()).printException();
|
||||
}
|
||||
|
||||
if (toOverride.contains("{"))
|
||||
{
|
||||
if (!toOverride.contains("}"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing } at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
}
|
||||
else if (toOverride.contains("}"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing { at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String nbt = toOverride.substring(toOverride.indexOf("{"));
|
||||
toOverride = toOverride.replace(nbt, "");
|
||||
try
|
||||
{
|
||||
tag = JsonToNBT.getTagFromJson(nbt);
|
||||
}
|
||||
catch (NBTException e)
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Error while parsing NBT at line " + i + " : " + e.getMessage()).printException();
|
||||
}
|
||||
|
||||
}
|
||||
else if (toOverride.contains("}"))
|
||||
String overridetype = "item";
|
||||
if (override.contains("("))
|
||||
{
|
||||
if (!override.contains(")"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing { at line " + i + " : " + currentline).printException();
|
||||
new InvalidConfigException("Missing ) at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String overridetype = "item";
|
||||
if (override.contains("("))
|
||||
overridetype = override.substring(0, override.indexOf(")") + 1);
|
||||
override =override.replace(overridetype, "");
|
||||
overridetype = overridetype.replace("(", "");
|
||||
overridetype = overridetype.replace(")", "");
|
||||
|
||||
}
|
||||
else if (override.contains(")"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing ( at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String modidToOverride = "minecraft";
|
||||
String modidOverride = "minecraft";
|
||||
|
||||
if (toOverride.contains(":"))
|
||||
modidToOverride = toOverride.replace(toOverride.substring(toOverride.indexOf(":")), "");
|
||||
|
||||
if (override.contains(":"))
|
||||
modidOverride = override.replace(override.substring(override.indexOf(":")), "");
|
||||
|
||||
if (Loader.isModLoaded(modidOverride) && Loader.isModLoaded(modidToOverride) && !errored)
|
||||
{
|
||||
|
||||
int meta = StringParser.getMeta(toOverride);
|
||||
if (meta == 0)
|
||||
toOverrideObject = StringParser.getBlock(toOverride);
|
||||
else
|
||||
toOverrideObject = StringParser.getBlockState(toOverride);
|
||||
|
||||
if (toOverrideObject != null)
|
||||
{
|
||||
if (!override.contains(")"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing ) at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
overridetype = override.substring(0, override.indexOf(")") + 1);
|
||||
override =override.replace(overridetype, "");
|
||||
overridetype = overridetype.replace("(", "");
|
||||
overridetype = overridetype.replace(")", "");
|
||||
|
||||
}
|
||||
else if (override.contains(")"))
|
||||
{
|
||||
errored = true;
|
||||
new InvalidConfigException("Missing ( at line " + i + " : " + currentline).printException();
|
||||
}
|
||||
|
||||
String modidToOverride = "minecraft";
|
||||
String modidOverride = "minecraft";
|
||||
|
||||
if (toOverride.contains(":"))
|
||||
modidToOverride = toOverride.replace(toOverride.substring(toOverride.indexOf(":")), "");
|
||||
|
||||
if (override.contains(":"))
|
||||
modidOverride = override.replace(override.substring(override.indexOf(":")), "");
|
||||
|
||||
if (Loader.isModLoaded(modidOverride) && Loader.isModLoaded(modidToOverride) && !errored)
|
||||
{
|
||||
|
||||
int meta = StringParser.getMeta(toOverride);
|
||||
if (meta == 0)
|
||||
toOverrideObject = StringParser.getBlock(toOverride);
|
||||
if (overridetype.equals("block"))
|
||||
overrideObject = StringParser.getBlockState(override);
|
||||
else
|
||||
toOverrideObject = StringParser.getBlockState(toOverride);
|
||||
overrideObject = StringParser.getItemStack(override);
|
||||
|
||||
if (toOverrideObject != null)
|
||||
if (overrideObject != null)
|
||||
{
|
||||
if (overridetype.equals("block"))
|
||||
overrideObject = StringParser.getBlockState(override);
|
||||
else
|
||||
overrideObject = StringParser.getItemStack(override);
|
||||
|
||||
if (overrideObject != null)
|
||||
NBTTagCompound keyComp = new NBTTagCompound();
|
||||
keyComp.setTag("nbttag", tag);
|
||||
if (toOverrideObject instanceof Block)
|
||||
{
|
||||
NBTTagCompound keyComp = new NBTTagCompound();
|
||||
keyComp.setTag("nbttag", tag);
|
||||
if (toOverrideObject instanceof Block)
|
||||
{
|
||||
keyComp.setString("block", ((Block) toOverrideObject).getRegistryName().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
keyComp.setInteger("stateid", Block.getStateId((IBlockState) toOverrideObject));
|
||||
keyComp.setString("block", ((IBlockState) toOverrideObject).getBlock().getRegistryName().toString());
|
||||
}
|
||||
OVERRIDE_OBJECTS.put(keyComp, overrideObject);
|
||||
keyComp.setString("block", ((Block) toOverrideObject).getRegistryName().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
keyComp.setInteger("stateid", Block.getStateId((IBlockState) toOverrideObject));
|
||||
keyComp.setString("block", ((IBlockState) toOverrideObject).getBlock().getRegistryName().toString());
|
||||
}
|
||||
OVERRIDE_OBJECTS.put(keyComp, overrideObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasCustomOverrideModel(IBlockState state, NBTTagCompound tag)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public class PickupHandler
|
|||
}
|
||||
}
|
||||
else
|
||||
return true && handleProtections((EntityPlayerMP) player, toPickUp);
|
||||
return handleProtections((EntityPlayerMP) player, toPickUp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ public class PickupHandler
|
|||
}
|
||||
}
|
||||
else
|
||||
return true && handleProtections((EntityPlayerMP) player, toPickUp);
|
||||
return handleProtections((EntityPlayerMP) player, toPickUp);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import tschipp.carryon.common.event.ItemEntityEvents;
|
|||
import tschipp.carryon.common.event.ItemEvents;
|
||||
import tschipp.carryon.common.item.ItemEntity;
|
||||
import tschipp.carryon.common.item.ItemTile;
|
||||
import tschipp.carryon.compat.llibrary.LLibraryEvents;
|
||||
import tschipp.carryon.compat.obfuscate.ObfuscateEvents;
|
||||
|
||||
public class RegistrationHandler
|
||||
|
|
@ -52,6 +53,9 @@ public class RegistrationHandler
|
|||
|
||||
if(Loader.isModLoaded("obfuscate"))
|
||||
MinecraftForge.EVENT_BUS.register(new ObfuscateEvents());
|
||||
|
||||
if(Loader.isModLoaded("llibrary"))
|
||||
MinecraftForge.EVENT_BUS.register(new LLibraryEvents());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import java.util.Set;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
|
@ -32,6 +34,9 @@ import net.minecraft.util.text.TextFormatting;
|
|||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.ClickEvent.Action;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import tschipp.carryon.CarryOn;
|
||||
|
|
@ -45,7 +50,7 @@ public class ItemTile extends Item
|
|||
{
|
||||
|
||||
public static final String TILE_DATA_KEY = "tileData";
|
||||
public static final String[] FACING_KEYS = new String[] { "rotation", "rot", "facing", "face", "direction", "dir", "front" };
|
||||
public static final String[] FACING_KEYS = new String[] { "rotation", "rot", "facing", "face", "direction", "dir", "front", "forward" };
|
||||
|
||||
public ItemTile()
|
||||
{
|
||||
|
|
@ -127,14 +132,29 @@ public class ItemTile extends Item
|
|||
|
||||
if (prop instanceof PropertyDirection && this.equal(allowedValues, EnumFacing.HORIZONTALS))
|
||||
{
|
||||
world.setBlockState(pos2, containedstate.withProperty(prop, containedblock instanceof BlockStairs ? facing2 : facing2.getOpposite()));
|
||||
set = true;
|
||||
BlockSnapshot snapshot = new BlockSnapshot(world, pos2, containedstate);
|
||||
PlaceEvent event = new PlaceEvent(snapshot, world.getBlockState(pos), player, hand);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (!event.isCanceled())
|
||||
{
|
||||
world.setBlockState(pos2, containedstate.withProperty(prop, containedblock instanceof BlockStairs ? facing2 : facing2.getOpposite()));
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
else if (prop instanceof PropertyDirection && this.equal(allowedValues, EnumFacing.VALUES))
|
||||
{
|
||||
facing2 = EnumFacing.getFacingFromVector((float) vec.x, (float) vec.y, (float) vec.z);
|
||||
world.setBlockState(pos2, containedstate.withProperty(prop, facing2.getOpposite()));
|
||||
set = true;
|
||||
|
||||
BlockSnapshot snapshot = new BlockSnapshot(world, pos2, containedstate);
|
||||
PlaceEvent event = new PlaceEvent(snapshot, world.getBlockState(pos), player, hand);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (!event.isCanceled())
|
||||
{
|
||||
world.setBlockState(pos2, containedstate.withProperty(prop, facing2.getOpposite()));
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,8 +164,7 @@ public class ItemTile extends Item
|
|||
{
|
||||
NBTTagCompound tag = getTileData(stack);
|
||||
Set<String> keys = tag.getKeySet();
|
||||
keytester:
|
||||
for (String key : keys)
|
||||
keytester: for (String key : keys)
|
||||
{
|
||||
for (String facingKey : FACING_KEYS)
|
||||
{
|
||||
|
|
@ -155,7 +174,7 @@ public class ItemTile extends Item
|
|||
switch (type)
|
||||
{
|
||||
case "TAG_String":
|
||||
tag.setString(key, facing2.getOpposite().getName());
|
||||
tag.setString(key, CharMatcher.JAVA_UPPER_CASE.matchesAllOf(tag.getString(key)) ? facing2.getOpposite().getName().toUpperCase() : facing2.getOpposite().getName());
|
||||
break;
|
||||
case "TAG_Int":
|
||||
tag.setInteger(key, facing2.getOpposite().getIndex());
|
||||
|
|
@ -166,7 +185,7 @@ public class ItemTile extends Item
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break keytester;
|
||||
}
|
||||
}
|
||||
|
|
@ -174,20 +193,33 @@ public class ItemTile extends Item
|
|||
}
|
||||
|
||||
if (!set)
|
||||
world.setBlockState(pos2, containedstate);
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos2);
|
||||
if (tile != null)
|
||||
{
|
||||
tile.readFromNBT(getTileData(stack));
|
||||
tile.setPos(pos2);
|
||||
BlockSnapshot snapshot = new BlockSnapshot(world, pos2, containedstate);
|
||||
PlaceEvent event = new PlaceEvent(snapshot, world.getBlockState(pos), player, hand);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (!event.isCanceled())
|
||||
{
|
||||
world.setBlockState(pos2, containedstate);
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (set)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(pos2);
|
||||
if (tile != null)
|
||||
{
|
||||
tile.readFromNBT(getTileData(stack));
|
||||
tile.setPos(pos2);
|
||||
}
|
||||
clearTileData(stack);
|
||||
player.playSound(containedblock.getSoundType().getPlaceSound(), 1.0f, 0.5f);
|
||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
||||
player.getEntityData().removeTag("overrideKey");
|
||||
ItemEvents.sendPacket(player, 9, 0);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
clearTileData(stack);
|
||||
player.playSound(containedblock.getSoundType().getPlaceSound(), 1.0f, 0.5f);
|
||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
||||
player.getEntityData().removeTag("overrideKey");
|
||||
ItemEvents.sendPacket(player, 9, 0);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,107 @@
|
|||
package tschipp.carryon.compat.llibrary;
|
||||
|
||||
import net.ilexiconn.llibrary.client.event.PlayerModelEvent;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.model.ModelPlayer;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import tschipp.carryon.common.config.CarryOnConfig;
|
||||
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;
|
||||
|
||||
public class LLibraryEvents
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public void setAngles(PlayerModelEvent.SetRotationAngles event)
|
||||
{
|
||||
if (!CarryOnConfig.settings.renderArms)
|
||||
return;
|
||||
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
ModelBiped modelBiped = event.getModel();
|
||||
if (modelBiped instanceof ModelPlayer)
|
||||
{
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
ModelPlayer model = (ModelPlayer) modelBiped;
|
||||
|
||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemEntity.hasEntityData(stack))
|
||||
{
|
||||
|
||||
float rotation = 0;
|
||||
|
||||
if (player.isRiding() && player.getRidingEntity() instanceof EntityLivingBase)
|
||||
rotation = 0;
|
||||
else
|
||||
rotation = 0;
|
||||
|
||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||
if (overrider != null)
|
||||
{
|
||||
double[] rotLeft = null;
|
||||
double[] rotRight = null;
|
||||
if (overrider.getRenderRotationLeftArm() != null)
|
||||
rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||
if (overrider.getRenderRotationRightArm() != null)
|
||||
rotRight = ScriptParseHelper.getXYZArray(overrider.getRenderRotationRightArm());
|
||||
|
||||
boolean renderRight = overrider.isRenderRightArm();
|
||||
boolean renderLeft = overrider.isRenderLeftArm();
|
||||
|
||||
if (renderLeft && rotLeft != null)
|
||||
{
|
||||
render(model.bipedLeftArm, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
render(model.bipedLeftArmwear, (float) rotLeft[0], (float) rotLeft[2], rotation);
|
||||
}
|
||||
else if (renderLeft)
|
||||
{
|
||||
render(model.bipedLeftArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
render(model.bipedLeftArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
}
|
||||
|
||||
if (renderRight && rotRight != null)
|
||||
{
|
||||
render(model.bipedRightArm, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
render(model.bipedRightArmwear, (float) rotRight[0], (float) rotRight[2], rotation);
|
||||
}
|
||||
else if (renderRight)
|
||||
{
|
||||
render(model.bipedRightArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
render(model.bipedRightArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
render(model.bipedRightArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
render(model.bipedRightArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation);
|
||||
render(model.bipedLeftArm, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
render(model.bipedLeftArmwear, 0.8F + (player.isSneaking() ? 0.2f : 0f) - (stack.getItem() == RegistrationHandler.itemEntity ? -0.2f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void render(ModelRenderer arm, float x, float z, float rotation)
|
||||
{
|
||||
arm.rotateAngleX = (float) -x;
|
||||
arm.rotateAngleY = (float) -Math.toRadians(rotation);
|
||||
arm.rotateAngleZ = (float) z;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import net.minecraft.client.model.ModelRenderer;
|
|||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
|
@ -27,6 +28,9 @@ public class ObfuscateEvents
|
|||
if(!CarryOnConfig.settings.renderArms)
|
||||
return;
|
||||
|
||||
if(Loader.isModLoaded("llibrary"))
|
||||
return;
|
||||
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
float partialticks = event.getPartialTicks();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
{
|
||||
"modid" : "carryon",
|
||||
"name" : "Carry On",
|
||||
"version" : "1.12", "mcversion" : "1.12.2",
|
||||
"version" : "1.12.1", "mcversion" : "1.12.2",
|
||||
"url" : "",
|
||||
"credits" : "Tschipp, Purplicious_Cow, cy4n",
|
||||
"authorList" : ["Tschipp, Purplicious_Cow, cy4n"],
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user