Some code cleanup for 1.15 (#6362)

This commit is contained in:
ichttt authored and LexManos committed 2019-12-18 20:39:41 -08:00
1 parent 30b530836a
commit 747cb0f151
7 files changed
+26 -27

No files matched your search

@@ -116,7 +116,7 @@ import net.minecraft.world.ILightReader;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.client.event.ColorHandlerEvent;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.client.event.DrawHighlightEvent;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.client.event.FOVUpdateEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
@@ -164,12 +164,12 @@ public class ForgeHooksClient
switch (target.getType()) {
case BLOCK:
if (!(target instanceof BlockRayTraceResult)) return false;
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent.HighlightBlock(context, info, target, subID, partialTicks));
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightBlock(context, info, target, subID, partialTicks));
case ENTITY:
if (!(target instanceof EntityRayTraceResult)) return false;
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent.HighlightEntity(context, info, target, subID, partialTicks));
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightEntity(context, info, target, subID, partialTicks));
}
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent(context, info, target, subID, partialTicks));
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent(context, info, target, subID, partialTicks));
}
public static void dispatchRenderLast(WorldRenderer context, MatrixStack mat, float partialTicks)
@@ -31,9 +31,8 @@ import net.minecraft.client.renderer.WorldRenderer;
* An event called whenever the selection highlight around blocks is about to be rendered.
* Canceling this event stops the selection highlight from being rendered.
*/
//TODO: in 1.15 rename to DrawHighlightEvent
@Cancelable
public class DrawBlockHighlightEvent extends Event
public class DrawHighlightEvent extends Event
{
private final WorldRenderer context;
private final ActiveRenderInfo info;
@@ -41,7 +40,7 @@ public class DrawBlockHighlightEvent extends Event
private final int subID;
private final float partialTicks;
public DrawBlockHighlightEvent(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
public DrawHighlightEvent(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
{
this.context = context;
this.info = info;
@@ -60,7 +59,7 @@ public class DrawBlockHighlightEvent extends Event
* A variant of the DrawBlockHighlightEvent only called when a block is highlighted.
*/
@Cancelable
public static class HighlightBlock extends DrawBlockHighlightEvent
public static class HighlightBlock extends DrawHighlightEvent
{
public HighlightBlock(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
{
@@ -79,7 +78,7 @@ public class DrawBlockHighlightEvent extends Event
* Canceling this event has no effect.
*/
@Cancelable
public static class HighlightEntity extends DrawBlockHighlightEvent
public static class HighlightEntity extends DrawHighlightEvent
{
public HighlightEntity(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
{
@@ -48,7 +48,7 @@ import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.common.crafting.CompoundIngredient;
import net.minecraftforge.common.crafting.ConditionalRecipe;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.IngredientNBT;
import net.minecraftforge.common.crafting.NBTIngredient;
import net.minecraftforge.common.crafting.VanillaIngredientSerializer;
import net.minecraftforge.common.crafting.conditions.AndCondition;
import net.minecraftforge.common.crafting.conditions.FalseCondition;
@@ -190,7 +190,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
CraftingHelper.register(TagEmptyCondition.Serializer.INSTANCE);
CraftingHelper.register(new ResourceLocation("forge", "compound"), CompoundIngredient.Serializer.INSTANCE);
CraftingHelper.register(new ResourceLocation("forge", "nbt"), IngredientNBT.Serializer.INSTANCE);
CraftingHelper.register(new ResourceLocation("forge", "nbt"), NBTIngredient.Serializer.INSTANCE);
CraftingHelper.register(new ResourceLocation("minecraft", "item"), VanillaIngredientSerializer.INSTANCE);
event.getRegistry().register(new ConditionalRecipe.Serializer<IRecipe<?>>().setRegistryName(new ResourceLocation("forge", "conditional")));
@@ -30,11 +30,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
//TODO: 1.15 Rename to NBTIngredient to match naming.
public class IngredientNBT extends Ingredient
public class NBTIngredient extends Ingredient
{
private final ItemStack stack;
protected IngredientNBT(ItemStack stack)
protected NBTIngredient(ItemStack stack)
{
super(Stream.of(new Ingredient.SingleItemList(stack)));
this.stack = stack;
@@ -73,22 +72,22 @@ public class IngredientNBT extends Ingredient
return json;
}
public static class Serializer implements IIngredientSerializer<IngredientNBT>
public static class Serializer implements IIngredientSerializer<NBTIngredient>
{
public static final Serializer INSTANCE = new Serializer();
@Override
public IngredientNBT parse(PacketBuffer buffer) {
return new IngredientNBT(buffer.readItemStack());
public NBTIngredient parse(PacketBuffer buffer) {
return new NBTIngredient(buffer.readItemStack());
}
@Override
public IngredientNBT parse(JsonObject json) {
return new IngredientNBT(CraftingHelper.getItemStack(json, true));
public NBTIngredient parse(JsonObject json) {
return new NBTIngredient(CraftingHelper.getItemStack(json, true));
}
@Override
public void write(PacketBuffer buffer, IngredientNBT ingredient) {
public void write(PacketBuffer buffer, NBTIngredient ingredient) {
buffer.writeItemStack(ingredient.stack);
}
}