Compare commits

...

40 Commits

Author SHA1 Message Date
Tschipp
77a4d1ac91 added stackable to blacklist 2023-04-25 22:45:46 +02:00
Tschipp
e015a273e7 Fixed bugs 2023-04-25 22:25:40 +02:00
Tschipp
fe85ff0075
Merge pull request #479 from redd-rl/patch-2
Update Configs.java
2023-04-24 13:54:58 +02:00
redd
4aa7223849
Update Configs.java
my second time pull requesting this but PLEASE take moving elevators blocks OFF the whitelist, they need to be blacklisted because they crash a server when you pick them up using CarryOn
2023-03-26 19:14:36 +02:00
Tschipp
7f68fae6f7 Removed Debug Log Spam 2021-10-22 12:11:18 +02:00
Tschipp
a595db4d78 Fixed bug where items weren't correctly ejected 2021-10-22 00:17:20 +02:00
Tschipp
f72a8b15d4 updated jenkinsfile 2021-10-20 22:41:25 +02:00
Tschipp
b7c2d8e898 Should now be harder to place blocks where they shouldn't be placed 2021-10-20 22:38:34 +02:00
Tschipp
43767969dd Merge remote-tracking branch 'origin/1.12' into 1.12 2021-04-10 10:59:46 +02:00
Tschipp
9503120d58 Updated configs, improved compatibility, fixed sponge server issue 2021-04-10 10:59:42 +02:00
Tschipp
7285284226
Merge pull request #243 from KandiPanda/1.12
Added option to exempt tamed hostile mobs from restrictions on carrying hostile mobs.
2020-06-12 16:05:29 +02:00
KandiPanda
afe45abd1b
Update PickupHandler.java
Removed redundant EntityTameable check from within code already covered by another EntityTameable check (would always be "true" anyways).
Removed redundant EntityTameable check and contents from within the "else" of same outer check (else means it's already failed, and will never succeed this check or run the code within it anyways).
2020-06-12 01:52:18 -05:00
KandiPanda
b0e694f024
Update PickupHandler.java 2020-06-11 23:04:46 -05:00
KandiPanda
3906ea4a1e
Update Configs.java
Add tamedHostileMobExemption option
2020-06-11 22:59:53 -05:00
Tschipp
cc03c7f687
Merge pull request #237 from jaredlll08/1.12
http -> https
2020-05-06 20:39:29 +02:00
Jared
08fd683757
http -> https 2020-05-06 16:35:38 +02:00
Tschipp
dc1144812a
Update README.md 2020-05-05 13:51:37 +02:00
Tschipp
7ac73269e0
Update README.md 2020-05-05 13:51:18 +02:00
Tschipp
d948c37146 Please work now 2020-05-05 11:14:54 +02:00
Tschipp
13313270cf SignJar oof 2020-05-05 10:42:01 +02:00
Tschipp
07426f8acd Updated Jar Signing 2020-05-05 10:22:13 +02:00
Tschipp
11e259369f Edited Base Archive Name 2020-05-05 09:32:04 +02:00
Tschipp
d6952d89eb Build Test 2020-05-04 10:52:12 +02:00
Tschipp
2b687ed23b Added stuff to enable CI 2020-05-04 10:44:37 +02:00
Tschipp
92ebde173f Merge remote-tracking branch 'origin/1.12' into 1.12 2020-05-04 09:56:20 +02:00
Tschipp
884cbeae73 Fixed some stuff 2020-05-04 09:56:13 +02:00
Tschipp
915383423f
Merge pull request #223 from vanja-san/patch-1
Create ru_RU.lang
2020-03-21 14:35:28 +01:00
The_BadUser
c597e381a0
Create ru_RU.lang 2020-03-20 19:24:49 +07:00
Tschipp
40e9f2eece Merge remote-tracking branch 'origin/1.12' into 1.12 2019-10-30 16:27:33 +01:00
Tschipp
1aa3d25872 Added more configs 2019-10-30 16:27:30 +01:00
Tschipp
610ce078db
Merge pull request #200 from Eufranio/1.12
Create pt_BR.lang
2019-10-30 16:27:13 +01:00
Tschipp
b43b91f158
Merge pull request #203 from Barteks2x/1.12
Fix check for multiple tile/entity items, handle switching dimensions correctly. Fixes #201.
2019-10-30 15:57:10 +01:00
Barteks2x
c82c0d97a2 Bump version number, remove early return 2019-10-30 11:39:26 +01:00
Barteks2x
7be7583898 Fix check for multiple tile/entity items, handle switching dimensions correctly. Fixes #201. 2019-10-30 11:08:37 +01:00
Eufranio
91fb127922
Create pt_BR.lang 2019-10-16 18:44:19 -03:00
Tschipp
2b864fd7fe Merge remote-tracking branch 'origin/1.12' into 1.12 2019-06-26 16:02:49 +02:00
Tschipp
62246f935b mcmod 2019-06-26 16:02:14 +02:00
Tschipp
7174a92b69 LLibrary Support 2019-06-26 16:01:26 +02:00
Tschipp
033747916b
Merge pull request #177 from jellysquid3/1.12
Do not parse Mobends configuration every time an entity is rendered
2019-05-20 14:01:51 +02:00
Angeline
5727bea7ed
Do not parse Mobends configuration every time an entity is rendered
Drastically improves performance
2019-05-10 15:57:30 -05:00
24 changed files with 883 additions and 327 deletions

2
.gitignore vendored
View File

@ -1,5 +1,6 @@
# eclipse
bin
oldBuilds
*.launch
.settings
.metadata
@ -22,4 +23,3 @@ build
eclipse
run
gradle\.properties

32
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env groovy
pipeline {
agent any
tools {
jdk "jdk8u292-b10"
}
stages {
stage('Clean') {
steps {
withCredentials([file(credentialsId: 'mod_build_secrets', variable: 'ORG_GRADLE_PROJECT_secretFile')]) {
echo 'Cleaning Project'
sh 'chmod +x gradlew'
sh './gradlew clean'
}
}
}
stage('Build and Deploy') {
steps {
withCredentials([file(credentialsId: 'mod_build_secrets', variable: 'ORG_GRADLE_PROJECT_secretFile')]) {
echo 'Building and Deploying to Maven'
sh './gradlew build publish'
}
}
}
}
post {
always {
archive 'build/libs/**.jar'
}
}
}

View File

@ -1,2 +1,16 @@
# Carry On [![](http://cf.way2muchnoise.eu/carry-on.svg)](https://minecraft.curseforge.com/projects/carry-on) [![](http://cf.way2muchnoise.eu/versions/carry-on.svg)](https://minecraft.curseforge.com/projects/carry-on)
To use CarryOn in your projects, include this in your build.gradle:
```
repositories {
maven {
url "https://maven.blamejared.com/"
}
}
dependencies {
deobfCompile "tschipp.carryon:carryon-MCVERSION:MODVERSION"
}
```
Make sure to replace `MCVERSION` and `MODVERSION` with the appropriate versions.

View File

@ -1,34 +1,67 @@
buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
maven { url = 'https://maven.minecraftforge.net/' }
mavenCentral()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:3.+'
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'maven-publish'
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
if (project.hasProperty('secretFile')) {
loadSecrets(new File((String) findProperty('secretFile')))
}
apply plugin: 'net.minecraftforge.gradle.forge'
version = "1.0"
version = "${project.version}"
group = "tschipp.carryon"
archivesBaseName = "carryon"
archivesBaseName = "carryon-${minecraft_version}"
sourceCompatibility = targetCompatibility = '1.8'
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}
minecraft {
version = "1.12.2-14.23.4.2765"
runDir = "run"
mappings = "snapshot_20171003"
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
//mappings channel: 'snapshot', version: '20171003-1.12'
mappings channel: 'snapshot', version: '20171003-1.12'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
}
server {
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
}
}
}
repositories {
@ -37,27 +70,114 @@ repositories {
maven { url = "https://mrcrayfish.com/maven" }
maven {
url "https://maven.mcmoddev.com/"
}
}
dependencies {
// deobfCompile "net.darkhax.gamestages:GameStages-1.12.2:2.0.91"
compile "com.mrcrayfish:obfuscate:0.2.6-1.12.2"
dependencies {
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2860'
compile "com.mrcrayfish:obfuscate:0.2.6-1.12.2"
compile "net.ilexiconn:llibrary:1.7.9-1.12.2:dev"
}
jar {
manifest {
attributes([
"Specification-Title": "examplemod",
"Specification-Vendor": "examplemodsareus",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"examplemodsareus",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
description = 'Creates a JAR containing the source code.'
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
description = 'Creates a JAR containing the JavaDocs.'
from javadoc.destinationDir
classifier = 'javadoc'
}
task deobfJar(type: Jar) {
description = 'Creates a JAR containing the non-obfuscated compiled code.'
from sourceSets.main.output
classifier = "deobf"
}
artifacts {
archives sourcesJar
archives javadocJar
archives deobfJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
// Allows the maven pom file to be modified.
pom.withXml {
// Go through all the dependencies.
asNode().dependencies.dependency.each { dep ->
println 'Surpressing artifact ' + dep.artifactId.last().value().last() + ' from maven dependencies.'
assert dep.parent().remove(dep)
}
}
artifact sourcesJar {
classifier 'sources'
}
artifact javadocJar {
classifier 'javadoc'
}
artifact deobfJar {
classifier 'deobf'
}
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
inputs.property "mcversion", project.minecraft_version
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version':project.version, 'mcversion':project.minecraft.version
expand 'version':project.version, 'mcversion':project.minecraft_version
}
from(sourceSets.main.resources.srcDirs) {
@ -65,24 +185,24 @@ processResources {
}
}
task signJar(type: SignJar, dependsOn: reobfJar) {
// Skips if the keyStore property is missing.
onlyIf {
project.hasProperty('keyStore')
}
// findProperty allows us to reference the property without it existing.
// Using project.propName would cause the script to fail validation if
// the property did not exist.
keyStore = project.findProperty('keyStore')
alias = project.findProperty('keyStoreAlias')
storePass = project.findProperty('keyStorePass')
keyPass = project.findProperty('keyStoreKeyPass')
inputFile = jar.archivePath
outputFile = jar.archivePath
}
//task signJar(type: SignJar, dependsOn: reobfJar) {
//
// // Skips if the keyStore property is missing.
// onlyIf {
// project.hasProperty('modkeyStore')
// }
//
// // findProperty allows us to reference the property without it existing.
// // Using project.propName would cause the script to fail validation if
// // the property did not exist.
// keyStore = project.findProperty('modkeyStore')
// alias = project.findProperty('modkeyStoreAlias')
// storePass = project.findProperty('modkeyStorePass')
// keyPass = project.findProperty('modkeyStoreKeyPass')
// inputFile = jar.archivePath
// outputFile = jar.archivePath
//}
// Runs this task automatically when build is ran.
build.dependsOn signJar
//build.dependsOn signJar

5
gradle.properties Normal file
View File

@ -0,0 +1,5 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
version=1.12.7
minecraft_version=1.12.2

Binary file not shown.

View File

@ -1,6 +1,5 @@
#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip

View File

@ -1,24 +1,27 @@
package tschipp.carryon;
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;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
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.network.simpleimpl.SimpleNetworkWrapper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
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;
import java.io.File;
@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)
@ -27,20 +30,23 @@ public class CarryOn {
@SidedProxy(clientSide = "tschipp.carryon.client.ClientProxy", serverSide = "tschipp.carryon.common.CommonProxy")
public static CommonProxy proxy;
//
// Instance
@Instance(CarryOn.MODID)
public static CarryOn instance;
public static final String MODID = "carryon";
public static final String VERSION = "1.12";
public static final String VERSION = "1.12.3";
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/";
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2386,);after:gamestages;";
public static final String CERTIFICATE_FINGERPRINT = "55e88f24d04398481ae6f1ce76f65fd776f14227";
public static final String CERTIFICATE_FINGERPRINT = "fd21553434f4905f2f73ea7838147ac4ea07bd88";
public static File CONFIGURATION_FILE;
public static boolean FINGERPRINT_VIOLATED = false;
public static SimpleNetworkWrapper network;
@EventHandler
@ -66,9 +72,42 @@ public class CarryOn {
}
@EventHandler
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");
}
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;
}
});
}
}

View File

@ -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);

View File

@ -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;
@ -58,6 +62,8 @@ import tschipp.carryon.network.server.SyncKeybindPacket;
public class RenderEvents
{
private boolean obfuscatePresent = Loader.isModLoaded("obfuscate");
private static boolean initModels;
/*
@ -116,7 +122,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 +465,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 +562,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();
@ -619,16 +634,23 @@ public class RenderEvents
arm.isHidden = true;
}
private boolean mobendsPresent = Loader.isModLoaded("mobends");
private boolean mobendsConfigLoaded = false;
private boolean mobendsPlayersAnimated = false;
public boolean handleMobends()
{
if (Loader.isModLoaded("mobends"))
if (mobendsPresent && !mobendsConfigLoaded)
{
Configuration config = new Configuration(new File(CarryOn.CONFIGURATION_FILE.getPath().substring(0, CarryOn.CONFIGURATION_FILE.getPath().length() - 16), "mobends.cfg"));
boolean renderPlayer = config.get("animated", "player", true).getBoolean();
return !renderPlayer;
mobendsPlayersAnimated = config.get("animated", "player", true).getBoolean();
mobendsConfigLoaded = true;
}
return true;
return !mobendsPlayersAnimated;
}
public static boolean isChest(Block block)

View File

@ -34,6 +34,9 @@ public class Configs {
@Comment("Whether hostile mobs should be able to picked up in survival mode")
public boolean pickupHostileMobs = false;
@Comment("Whether tamed hostile mobs should be exempt from the above")
public boolean tamedHostileMobExemption = true;
@Comment("Larger Entities slow down the player more")
public boolean heavyEntities = true;
@ -116,12 +119,11 @@ public class Configs {
"minecraft:waterlily",
"minecraft:cake",
"animania:block_trough",
"animania:block_invisiblock",
"animania:invisiblock",
"colossalchests:*",
"ic2:*",
"bigreactors:*",
"forestry:*",
"tconstruct:*",
"rustic:*",
"botania:*",
"astralsorcery:*",
@ -171,12 +173,46 @@ 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",
"architecturecraft:*",
"blockcraftery:*",
"dakimakuramod:*",
"stackable:*",
"placeableitems:*",
"dumpsterdiving:powergrinder",
"dumpsterdiving:poweringot",
"dumpsterdiving:trash_furn",
"dumpsterdiving:powerprocessor",
"dumpsterdiving:rep_casing",
"dumpsterdiving:trash_furn_g",
"dumpsterdiving:trash_furn_n",
"*door*",
"waystones:*",
"immersiverailroading:*",
"integrateddynamics:*",
"bloodmagic:*",
"rftools:screen",
"rftools:creative_screen",
"movingelevators:elevator_block",
"movingelevators:display_block",
"forgemultipartcbe:*",
"integrateddynamics:cable",
"mekanismgenerators:wind_generator",
"stackable:*"
};
@Comment("Entities that cannot be picked up")
@ -191,13 +227,22 @@ public class Configs {
"minecraft:item_frame",
"minecraft:painting",
"minecraft:shulker_bullet",
"animania:textures/entity/pigs/hamster_tarou.png",
"animania:hamster",
"animania:ferret*",
"animania:hedgehog*",
"animania:cart",
"animania:wagon",
"mynko:*"
"mynko:*",
"astikorcarts:*",
"dakimakuramod:*",
"tektopia:*",
"mocreatures:*",
"pixelmon:*",
"thebetweenlands:draeton**",
"mysticalworld:*",
"securitycraft:*",
"taterzens:npc",
"minecolonies:*"
};
@ -277,7 +322,7 @@ public class Configs {
"animania:cheese_mold;7->(block)animania:cheese_mold;7",
"animania:cheese_mold;8->(block)animania:cheese_mold;8",
"animania:cheese_mold;9->(block)animania:cheese_mold;9",
"animania:cheese_mold;10->(block)animania:cheese_mold;10",
"animania:cheese_mold;10->(block)animania:cheese_mold;10"
};
}

View File

@ -1,7 +1,5 @@
package tschipp.carryon.common.event;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
@ -37,6 +35,8 @@ import tschipp.carryon.common.item.ItemEntity;
import tschipp.carryon.common.scripting.CarryOnOverride;
import tschipp.carryon.common.scripting.ScriptChecker;
import java.util.List;
public class ItemEntityEvents
{
@ -57,7 +57,7 @@ public class ItemEntityEvents
{
String command = override.getCommandPlace();
if (command != null)
player.getServer().getCommandManager().executeCommand(player.getServer(), "/execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
player.getServer().getCommandManager().executeCommand(player.getServer(), "execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
}
}
}
@ -86,6 +86,21 @@ public class ItemEntityEvents
}
}
}
@SubscribeEvent(priority = EventPriority.HIGH)
public void onEntityRightClickSpecific(PlayerInteractEvent.EntityInteractSpecific event)
{
EntityPlayer player = event.getEntityPlayer();
if (player instanceof EntityPlayerMP)
{
ItemStack main = player.getHeldItemMainhand();
if (!main.isEmpty() && (main.getItem() == RegistrationHandler.itemTile || main.getItem() == RegistrationHandler.itemEntity))
{
event.setCanceled(true);
event.setCancellationResult(EnumActionResult.SUCCESS);
}
}
}
@SubscribeEvent(priority = EventPriority.HIGH)
public void onEntityRightClick(PlayerInteractEvent.EntityInteract event)
@ -132,10 +147,11 @@ public class ItemEntityEvents
if (entity instanceof EntityLiving)
((EntityLiving) entity).setHealth(0);
entity.setPosition(entity.posX, -200, entity.posZ);
entity.setDead();
player.setHeldItem(EnumHand.MAIN_HAND, stack);
event.setCanceled(true);
event.setCancellationResult(EnumActionResult.FAIL);
event.setCancellationResult(EnumActionResult.SUCCESS);
}
}
}
@ -191,11 +207,13 @@ public class ItemEntityEvents
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
ItemEvents.sendPacket(player, 9, 0);
event.setCanceled(true);
event.setCancellationResult(EnumActionResult.FAIL);
event.setCancellationResult(EnumActionResult.SUCCESS);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_HORSE_SADDLE, SoundCategory.PLAYERS, 0.5F, 1.5F);
}
else
{
event.setCanceled(true);
event.setCancellationResult(EnumActionResult.SUCCESS);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
return;
}
@ -203,6 +221,8 @@ public class ItemEntityEvents
}
else
{
event.setCanceled(true);
event.setCancellationResult(EnumActionResult.SUCCESS);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
return;
}
@ -210,6 +230,14 @@ public class ItemEntityEvents
}
event.setCanceled(true);
event.setCancellationResult(EnumActionResult.SUCCESS);
}
else if (!main.isEmpty() && main.getItem() == RegistrationHandler.itemTile)
{
event.setCanceled(true);
event.setCancellationResult(EnumActionResult.SUCCESS);
}
}

View File

@ -1,8 +1,12 @@
package tschipp.carryon.common.event;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@ -11,15 +15,18 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.SPacketHeldItemChange;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.MutableBlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.event.ClickEvent;
@ -84,7 +91,7 @@ public class ItemEvents
{
String command = override.getCommandPlace();
if (command != null)
player.getServer().getCommandManager().executeCommand(player.getServer(), "/execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
player.getServer().getCommandManager().executeCommand(player.getServer(), "execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
}
}
}
@ -106,23 +113,19 @@ public class ItemEvents
BlockPos pos = eitem.getPosition();
BlockPos finalPos = pos;
Block block = ItemTile.getBlock(stack);
if (!world.getBlockState(pos).getBlock().isReplaceable(world, pos) || !block.canPlaceBlockAt(world, pos))
boolean replaceable = world.getBlockState(pos).getBlock().isReplaceable(world, pos);
boolean placeable = block.canPlaceBlockAt(world, pos);
if (!replaceable || !placeable)
{
for (EnumFacing facing : EnumFacing.VALUES)
{
BlockPos offsetPos = pos.offset(facing);
if (world.getBlockState(offsetPos).getBlock().isReplaceable(world, offsetPos) && block.canPlaceBlockAt(world, offsetPos))
{
finalPos = offsetPos;
break;
}
}
finalPos = getBestPosForPlacement(block, pos, world);
}
world.setBlockState(finalPos, ItemTile.getBlockState(stack));
TileEntity tile = world.getTileEntity(finalPos);
if (tile != null)
{
tile.readFromNBT(ItemTile.getTileData(stack));
NBTTagCompound nbt = ItemTile.getTileData(stack);
ItemTile.updateTileLocation(nbt, finalPos);
tile.readFromNBT(nbt);
tile.setPos(finalPos);
}
ItemTile.clearTileData(stack);
@ -138,6 +141,28 @@ public class ItemEvents
}
private BlockPos getBestPosForPlacement(Block block, BlockPos pos, World world)
{
MutableBlockPos m = new MutableBlockPos(pos);
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
for (int i = 0; i < 64; i++)
{
for (int k = 0; k < 64; k++)
{
for (int j = 0; j + y < 256; j++)
{
m.setPos(x + i, y + j, z + k);
if (world.getBlockState(m).getBlock().isReplaceable(world, m) && block.canPlaceBlockAt(world, m))
return m;
}
}
}
return m;
}
@SubscribeEvent
public void onPlayerLogin(PlayerLoggedInEvent event)
{
@ -265,7 +290,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);
@ -367,7 +394,10 @@ public class ItemEvents
{
String command = override.getCommandInit();
if (command != null)
player.getServer().getCommandManager().executeCommand(player.getServer(), "/execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
{
CarryOn.LOGGER.info("Executing command: execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
player.getServer().getCommandManager().executeCommand(player.getServer(), "execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
}
}
}
@ -430,7 +460,7 @@ public class ItemEvents
boolean keepInv = rules.getBoolean("keepInventory");
boolean wasCarrying = player.inventory.hasItemStack(new ItemStack(RegistrationHandler.itemTile)) || player.inventory.hasItemStack(new ItemStack(RegistrationHandler.itemEntity));
if ((wasDead ? keepInv : true) && wasCarrying)
if (wasDead && keepInv && wasCarrying)
{
int carrySlot = original.inventory.currentItem;
@ -458,29 +488,32 @@ public class ItemEvents
if (!entity.world.isRemote)
{
boolean hasCarried = player.inventory.hasItemStack(new ItemStack(RegistrationHandler.itemTile)) || player.inventory.hasItemStack(new ItemStack(RegistrationHandler.itemEntity));
List<Integer> itemSlots = new ArrayList<>();
getSlots(player, RegistrationHandler.itemTile, itemSlots);
getSlots(player, RegistrationHandler.itemEntity, itemSlots);
ItemStack inHand = player.getHeldItemMainhand();
if (hasCarried)
if (itemSlots.size() > 1 || (itemSlots.size() > 0 && (inHand.getItem() != RegistrationHandler.itemTile && inHand.getItem() != RegistrationHandler.itemEntity)))
{
if (inHand.getItem() != RegistrationHandler.itemTile && inHand.getItem() != RegistrationHandler.itemEntity)
// if there is only one item, and it's in the hotbar, just
// force the selection there
// this is necessary, because when switching dimensions,
// Minecraft will reset selection to 0 for one tick
// and completely reset it to 0 when returning from the end
// if there are multiple, drop all of them, as it's likely a
// player trying to exploit a bug
if (itemSlots.size() == 1 && InventoryPlayer.isHotbar(itemSlots.get(0)))
{
int slotBlock = getSlot(player, RegistrationHandler.itemTile);
int slotEntity = getSlot(player, RegistrationHandler.itemEntity);
EntityItem item = null;
if (slotBlock != -1)
player.inventory.currentItem = itemSlots.get(0);
((EntityPlayerMP) player).connection.sendPacket(new SPacketHeldItemChange(player.inventory.currentItem));
sendPacket(player, itemSlots.get(0), 0);
}
else
{
for (int slotBlock : itemSlots)
{
ItemStack dropped = player.inventory.removeStackFromSlot(slotBlock);
item = new EntityItem(player.world, player.posX, player.posY, player.posZ, dropped);
}
if (slotEntity != -1)
{
ItemStack dropped = player.inventory.removeStackFromSlot(slotEntity);
item = new EntityItem(player.world, player.posX, player.posY, player.posZ, dropped);
}
if (item != null)
{
EntityItem item = new EntityItem(player.world, player.posX, player.posY, player.posZ, dropped);
player.world.spawnEntity(item);
sendPacket(player, 9, 0);
}
@ -493,7 +526,7 @@ public class ItemEvents
{
String command = override.getCommandLoop();
if (command != null)
player.getServer().getCommandManager().executeCommand(player.getServer(), "/execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
player.getServer().getCommandManager().executeCommand(player.getServer(), "execute " + player.getGameProfile().getName() + " ~ ~ ~ " + command);
}
}
@ -510,15 +543,14 @@ public class ItemEvents
}
}
public int getSlot(EntityPlayer player, Item item)
public void getSlots(EntityPlayer player, Item item, List<Integer> outputList)
{
for (int i = 0; i < player.inventory.getSizeInventory(); i++)
{
ItemStack stack = player.inventory.getStackInSlot(i);
if (stack.getItem() == item)
return i;
outputList.add(i);
}
return -1;
}
public static void sendPacket(EntityPlayer player, int currentItem, int hash)

View File

@ -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)
{

View File

@ -1,13 +1,7 @@
package tschipp.carryon.common.handler;
import java.lang.reflect.Method;
import java.util.UUID;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EnumCreatureType;
@ -18,17 +12,19 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.AttackEntityEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import tschipp.carryon.CarryOn;
import tschipp.carryon.common.config.CarryOnConfig;
import tschipp.carryon.common.item.ItemTile;
import tschipp.carryon.common.scripting.CarryOnOverride;
import tschipp.carryon.common.scripting.ScriptChecker;
import javax.annotation.Nullable;
import java.lang.reflect.Method;
import java.util.UUID;
public class PickupHandler
{
@ -135,6 +131,9 @@ public class PickupHandler
if (toPickUp instanceof EntityPlayer)
return false;
if(toPickUp.isDead)
return false;
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
if (override != null)
{
@ -200,7 +199,7 @@ public class PickupHandler
}
}
else
return true && handleProtections((EntityPlayerMP) player, toPickUp);
return handleProtections((EntityPlayerMP) player, toPickUp);
}
}
@ -219,73 +218,132 @@ public class PickupHandler
}
}
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
{
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
if(toPickUp instanceof EntityTameable) {
EntityTameable tamecheck = (EntityTameable) toPickUp;
UUID OwnerCheck = tamecheck.getOwnerId();
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || (CarryOnConfig.settings.tamedHostileMobExemption ? (OwnerCheck != null) : false) || player.isCreative()))
{
if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative()))
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || (CarryOnConfig.settings.tamedHostileMobExemption ? (OwnerCheck != null) : false) || player.isCreative()))
{
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative()))
{
if (toPickUp instanceof EntityTameable)
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
{
EntityTameable tame = (EntityTameable) toPickUp;
UUID owner = tame.getOwnerId();
UUID playerID = player.getUUID(player.getGameProfile());
if (owner != null && !owner.equals(playerID))
if (OwnerCheck != null && !OwnerCheck.equals(playerID))
return false;
}
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
{
try
{
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
Method getPlayerData = ReflectionHelper.findMethod(gameStageHelper, "getPlayerData", null, EntityPlayer.class);
Method hasStage = ReflectionHelper.findMethod(iStageData, "hasStage", null, String.class);
Object stageData = getPlayerData.invoke(null, player);
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
boolean has = (boolean) hasStage.invoke(stageData, condition);
if (has)
return handleProtections((EntityPlayerMP) player, toPickUp);
}
catch (Exception e)
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
{
try
{
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
Method getStageData = ReflectionHelper.findMethod(playerDataHandler, "getStageData", null, EntityPlayer.class);
Method hasUnlockedStage = ReflectionHelper.findMethod(iStageData, "hasUnlockedStage", null, String.class);
Object stageData = getStageData.invoke(null, player);
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
Method getPlayerData = ReflectionHelper.findMethod(gameStageHelper, "getPlayerData", null, EntityPlayer.class);
Method hasStage = ReflectionHelper.findMethod(iStageData, "hasStage", null, String.class);
Object stageData = getPlayerData.invoke(null, player);
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
boolean has = (boolean) hasUnlockedStage.invoke(stageData, condition);
boolean has = (boolean) hasStage.invoke(stageData, condition);
if (has)
return handleProtections((EntityPlayerMP) player, toPickUp);
}
catch (Exception ex)
catch (Exception e)
{
return handleProtections((EntityPlayerMP) player, toPickUp);
try
{
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
Method getStageData = ReflectionHelper.findMethod(playerDataHandler, "getStageData", null, EntityPlayer.class);
Method hasUnlockedStage = ReflectionHelper.findMethod(iStageData, "hasUnlockedStage", null, String.class);
Object stageData = getStageData.invoke(null, player);
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
boolean has = (boolean) hasUnlockedStage.invoke(stageData, condition);
if (has)
return handleProtections((EntityPlayerMP) player, toPickUp);
}
catch (Exception ex)
{
return handleProtections((EntityPlayerMP) player, toPickUp);
}
}
}
else
return handleProtections((EntityPlayerMP) player, toPickUp);
}
else
return true && handleProtections((EntityPlayerMP) player, toPickUp);
}
}
}
} else {
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
{
if ((CarryOnConfig.settings.pickupHostileMobs ? true : !toPickUp.isCreatureType(EnumCreatureType.MONSTER, false) || player.isCreative()))
{
if ((toPickUp.height <= CarryOnConfig.settings.maxEntityHeight && toPickUp.width <= CarryOnConfig.settings.maxEntityWidth || player.isCreative()))
{
double distance = pos.distanceSqToCenter(player.posX, player.posY + 0.5, player.posZ);
if (distance < Math.pow(CarryOnConfig.settings.maxDistance, 2))
{
if (CustomPickupOverrideHandler.hasSpecialPickupConditions(toPickUp))
{
try
{
Class<?> gameStageHelper = Class.forName("net.darkhax.gamestages.GameStageHelper");
Class<?> iStageData = Class.forName("net.darkhax.gamestages.data.IStageData");
Method getPlayerData = ReflectionHelper.findMethod(gameStageHelper, "getPlayerData", null, EntityPlayer.class);
Method hasStage = ReflectionHelper.findMethod(iStageData, "hasStage", null, String.class);
Object stageData = getPlayerData.invoke(null, player);
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
boolean has = (boolean) hasStage.invoke(stageData, condition);
if (has)
return handleProtections((EntityPlayerMP) player, toPickUp);
}
catch (Exception e)
{
try
{
Class<?> playerDataHandler = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler");
Class<?> iStageData = Class.forName("net.darkhax.gamestages.capabilities.PlayerDataHandler$IStageData");
Method getStageData = ReflectionHelper.findMethod(playerDataHandler, "getStageData", null, EntityPlayer.class);
Method hasUnlockedStage = ReflectionHelper.findMethod(iStageData, "hasUnlockedStage", null, String.class);
Object stageData = getStageData.invoke(null, player);
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
boolean has = (boolean) hasUnlockedStage.invoke(stageData, condition);
if (has)
return handleProtections((EntityPlayerMP) player, toPickUp);
}
catch (Exception ex)
{
return handleProtections((EntityPlayerMP) player, toPickUp);
}
}
}
else
return handleProtections((EntityPlayerMP) player, toPickUp);
}
}
}
}
}
}
return false;

View File

@ -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());
}

View File

@ -16,19 +16,7 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper;
*/
public class ReflectionUtil
{
/**
* Get a {@link MethodHandle} for a method.
*
* @param clazz
* The class
* @param methodNames
* The possible names of the method
* @param methodTypes
* The argument types of the method
* @param <T>
* The class
* @return The MethodHandle
*/
public static MethodHandle findMethod(final Class<?> clazz, final String methodName, @Nullable final String methodObfName, final Class<?>... parameterTypes)
{
final Method method = ReflectionHelper.findMethod(clazz, methodName, methodObfName, parameterTypes);
@ -42,15 +30,7 @@ public class ReflectionUtil
}
}
/**
* Get a {@link MethodHandle} for a field's getter.
*
* @param clazz
* The class
* @param fieldNames
* The possible names of the field
* @return The MethodHandle
*/
public static MethodHandle findFieldGetter(Class<?> clazz, String... fieldNames)
{
final Field field = ReflectionHelper.findField(clazz, fieldNames);
@ -65,15 +45,7 @@ public class ReflectionUtil
}
}
/**
* Get a {@link MethodHandle} for a field's setter.
*
* @param clazz
* The class
* @param fieldNames
* The possible names of the field
* @return The MethodHandle
*/
public static MethodHandle findFieldSetter(Class<?> clazz, String... fieldNames)
{
final Field field = ReflectionHelper.findField(clazz, fieldNames);

View File

@ -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,36 @@ 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)
{
NBTTagCompound tag = getTileData(stack);
updateTileLocation(tag, pos2);
tile.readFromNBT(tag);
// 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;
}
}
@ -288,6 +323,13 @@ public class ItemTile extends Item
tag.removeTag("stateid");
}
}
public static void updateTileLocation(NBTTagCompound tag, BlockPos pos)
{
tag.setInteger("x", pos.getX());
tag.setInteger("y", pos.getY());
tag.setInteger("z", pos.getZ());
}
public static NBTTagCompound getTileData(ItemStack stack)
{

View File

@ -1,23 +1,17 @@
package tschipp.carryon.common.scripting;
import com.google.gson.*;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import tschipp.carryon.CarryOn;
import tschipp.carryon.common.config.CarryOnConfig;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import com.google.gson.JsonElement;
import com.google.gson.JsonIOException;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import tschipp.carryon.CarryOn;
import tschipp.carryon.common.config.CarryOnConfig;
public class ScriptReader
{
@ -28,7 +22,7 @@ public class ScriptReader
public static void preInit(FMLPreInitializationEvent event)
{
CarryOn.CONFIGURATION_FILE = new File(event.getModConfigurationDirectory(), "carryon-scripts/");
CarryOn.CONFIGURATION_FILE = new File(event.getModConfigurationDirectory(), "carryon-scripts" + File.separator);
if (!CarryOn.CONFIGURATION_FILE.exists())
CarryOn.CONFIGURATION_FILE.mkdir();

View File

@ -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;
}
}

View File

@ -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();

View File

@ -0,0 +1,14 @@
carryon.category.settings=Configurações
carryon.category.blacklist=Não permitidos
carryon.category.modeloverrides=Substituições de Modelos (Avançado)
carryon.category.custompickupconditions=Condições Personalizadas para Segurar (Avançado)
carryon.category.whitelist=Permitidos
carryon.general.modeloverrides.modeloverrides=Substituições de Modelos
carryon.general.blacklist.forbiddenentities=Entidades que os jogadores não podem segurar
carryon.general.blacklist.forbiddentiles=Blocos que os jogadores não podem segurar
carryon.category.custompickupconditions.custompickupconditionsblocks=Condições Personalizadas para Segurar entidades
carryon.category.custompickupconditions.custompickupconditionsentities=Condições Personalizadas para Segurar entidades
key.carry.desc=Segurar
key.carry.category=Segurar

View File

@ -0,0 +1,14 @@
carryon.category.settings=Настройки
carryon.category.blacklist=Чёрный список
carryon.category.modeloverrides=Переопределения модели (Дополнительно)
carryon.category.custompickupconditions=Пользовательские условия поднятия (Дополнительно)
carryon.category.whitelist=Белый список
carryon.general.modeloverrides.modeloverrides=Переопределения модели
carryon.general.blacklist.forbiddenentities=Существа, которые игрок не может поднять
carryon.general.blacklist.forbiddentiles=Блоки, которые игрок не может поднять
carryon.category.custompickupconditions.custompickupconditionsblocks=Пользовательские условия поднятия блоков
carryon.category.custompickupconditions.custompickupconditionsentities=Пользовательские условия поднятия существ
key.carry.desc=Поднять
key.carry.category=Carry On

View File

@ -2,7 +2,7 @@
{
"modid" : "carryon",
"name" : "Carry On",
"version" : "1.12", "mcversion" : "1.12.2",
"version" : "1.12.3", "mcversion" : "1.12.2",
"url" : "",
"credits" : "Tschipp, Purplicious_Cow, cy4n",
"authorList" : ["Tschipp, Purplicious_Cow, cy4n"],