Script Checker Entity/Block Conditional
This commit is contained in:
parent
82e43a37e5
commit
ec04f72cc6
|
|
@ -36,6 +36,8 @@ public class CarryOnOverride
|
||||||
private String renderRotation;
|
private String renderRotation;
|
||||||
private String renderScale;
|
private String renderScale;
|
||||||
|
|
||||||
|
private boolean isBlock;
|
||||||
|
private boolean isEntity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -43,6 +45,22 @@ public class CarryOnOverride
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isBlock()
|
||||||
|
{
|
||||||
|
return isBlock;
|
||||||
|
}
|
||||||
|
public void setBlock(boolean isBlock)
|
||||||
|
{
|
||||||
|
this.isBlock = isBlock;
|
||||||
|
}
|
||||||
|
public boolean isEntity()
|
||||||
|
{
|
||||||
|
return isEntity;
|
||||||
|
}
|
||||||
|
public void setEntity(boolean isEntity)
|
||||||
|
{
|
||||||
|
this.isEntity = isEntity;
|
||||||
|
}
|
||||||
public NBTTagCompound getTypeBlockTag()
|
public NBTTagCompound getTypeBlockTag()
|
||||||
{
|
{
|
||||||
return typeBlockTag;
|
return typeBlockTag;
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,17 @@ public class ScriptChecker
|
||||||
NBTTagCompound nbt = tag;
|
NBTTagCompound nbt = tag;
|
||||||
|
|
||||||
for (CarryOnOverride override : ScriptReader.OVERRIDES)
|
for (CarryOnOverride override : ScriptReader.OVERRIDES)
|
||||||
|
{
|
||||||
|
if (override.isBlock())
|
||||||
{
|
{
|
||||||
if (matchesAll(override, block, meta, material, hardness, resistance, nbt))
|
if (matchesAll(override, block, meta, material, hardness, resistance, nbt))
|
||||||
return override;
|
return override;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static CarryOnOverride inspectEntity(Entity entity)
|
public static CarryOnOverride inspectEntity(Entity entity)
|
||||||
{
|
{
|
||||||
|
|
@ -57,15 +59,17 @@ public class ScriptChecker
|
||||||
entity.writeToNBT(tag);
|
entity.writeToNBT(tag);
|
||||||
|
|
||||||
for (CarryOnOverride override : ScriptReader.OVERRIDES)
|
for (CarryOnOverride override : ScriptReader.OVERRIDES)
|
||||||
|
{
|
||||||
|
if (override.isEntity())
|
||||||
{
|
{
|
||||||
if (matchesAll(override, name, height, width, health, tag))
|
if (matchesAll(override, name, height, width, health, tag))
|
||||||
return override;
|
return override;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean matchesAll(CarryOnOverride override, String name, float height, float width, float health, NBTTagCompound tag)
|
public static boolean matchesAll(CarryOnOverride override, String name, float height, float width, float health, NBTTagCompound tag)
|
||||||
{
|
{
|
||||||
boolean matchname = name == null ? true : name.equals(override.getTypeNameEntity());
|
boolean matchname = name == null ? true : name.equals(override.getTypeNameEntity());
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ public class ScriptReader
|
||||||
|
|
||||||
if (block != null)
|
if (block != null)
|
||||||
{
|
{
|
||||||
|
override.setBlock(true);
|
||||||
JsonElement name = block.get("name");
|
JsonElement name = block.get("name");
|
||||||
JsonElement meta = block.get("meta");
|
JsonElement meta = block.get("meta");
|
||||||
JsonElement material = block.get("material");
|
JsonElement material = block.get("material");
|
||||||
|
|
@ -93,6 +94,7 @@ public class ScriptReader
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
override.setEntity(true);
|
||||||
JsonElement name = entity.get("name");
|
JsonElement name = entity.get("name");
|
||||||
JsonElement health = entity.get("health");
|
JsonElement health = entity.get("health");
|
||||||
JsonElement height = entity.get("height");
|
JsonElement height = entity.get("height");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user