Converted Eternal Fabric into a proper fluid block

This commit is contained in:
Waterpicker 2019-11-28 03:03:01 -06:00
parent 2118ba3cc3
commit 5b1bd232ab
16 changed files with 92 additions and 25 deletions

View file

@ -7,6 +7,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
@ -53,7 +54,7 @@ public class DimDoors {
public static Logger log;
@SidedProxy(clientSide = "org.dimdev.dimdoors.proxy.ClientProxy",
serverSide = "org.dimdev.dimdoors.proxy.ServerProxy")
serverSide = "org.dimdev.dimdoors.proxy.CommonProxy")
public static IProxy proxy;
@Getter public static File configurationFolder;
@ -144,4 +145,8 @@ public class DimDoors {
public static void chat(Entity entity, String text, Object... translationArgs) {
entity.sendMessage(new TextComponentTranslation(text, translationArgs));
}
static {
FluidRegistry.enableUniversalBucket();
}
}

View file

@ -1,21 +1,30 @@
package org.dimdev.dimdoors.client;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.dimdev.dimdoors.shared.blocks.BlockFabricEternal;
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
import org.dimdev.dimdoors.shared.fluids.FluidLiquid;
import org.dimdev.dimdoors.shared.items.ModItems;
import static org.dimdev.dimdoors.shared.blocks.ModBlocks.ETERNAL_FABRIC;
@SideOnly(Side.CLIENT)
public final class ModelManager {
@ -25,7 +34,6 @@ public final class ModelManager {
registerColored(ModItems.FABRIC);
registerColored(ModItems.ANCIENT_FABRIC);
register(ModItems.UNRAVELLED_FABRIC);
register(ModItems.ETERNAL_FABRIC);
register(ModItems.WOOD_DIMENSIONAL_TRAPDOOR);
register(ModItems.IRON_DIMENSIONAL_DOOR);
register(ModItems.GOLD_DIMENSIONAL_DOOR);
@ -65,6 +73,16 @@ public final class ModelManager {
ModelLoader.setCustomStateMapper(ModBlocks.PERSONAL_DIMENSIONAL_DOOR, ignorePowered);
ModelLoader.setCustomStateMapper(ModBlocks.WARP_DIMENSIONAL_DOOR, ignorePowered);
ModelLoader.setCustomStateMapper(ETERNAL_FABRIC, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
return new ModelResourceLocation("dimdoors:eternal_fabric", "fluid");
}
});
ModelLoader.setCustomMeshDefinition(ItemBlock.getItemFromBlock(ETERNAL_FABRIC), stack -> new ModelResourceLocation("dimdoors:eternal_fabric", "fluid"));
ModelLoader.setCustomStateMapper(ModBlocks.DIMENSIONAL_PORTAL, new StateMap.Builder().ignore(BlockDoor.FACING, BlockDoor.HALF, BlockDoor.HINGE, BlockDoor.OPEN, BlockDoor.POWERED).build());
}

View file

@ -20,10 +20,11 @@ import org.dimdev.dimdoors.shared.tileentities.TileEntityEntranceRift;
import org.dimdev.dimdoors.shared.tileentities.TileEntityFloatingRift;
@SideOnly(Side.CLIENT)
public class ClientProxy implements IProxy {
public class ClientProxy extends CommonProxy {
@Override
public void onPreInitialization(FMLPreInitializationEvent event) {
super.onPreInitialization(event);
// Register client-side event handlers
MinecraftForge.EVENT_BUS.register(ModelManager.class);

View file

@ -5,11 +5,14 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.client.IRenderHandler;
import org.dimdev.dimdoors.shared.fluids.ModFluids;
public class ServerProxy implements IProxy {
public class CommonProxy implements IProxy {
@Override
public void onPreInitialization(FMLPreInitializationEvent event) {}
public void onPreInitialization(FMLPreInitializationEvent event) {
ModFluids.registerFluids();
}
@Override
public void onInitialization(FMLInitializationEvent event) {}

View file

@ -8,18 +8,20 @@ import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.shared.fluids.ModFluids;
import org.dimdev.dimdoors.shared.items.ModCreativeTabs;
import org.dimdev.dimdoors.shared.rifts.targets.EscapeTarget;
public class BlockFabricEternal extends BlockEmptyDrops { // TODO: make this a glowing red liquid
public class BlockFabricEternal extends BlockFluidClassic { // TODO: make this a glowing red liquid
public static final Material ETERNAL_FABRIC = new Material(MapColor.PINK);
public static final String ID = "eternal_fabric";
public static EscapeTarget exitLimbo = new EscapeTarget(true);
public BlockFabricEternal() {
super(ETERNAL_FABRIC);
super(ModFluids.ETERNAL_FABRIC, ETERNAL_FABRIC);
setRegistryName(new ResourceLocation(DimDoors.MODID, ID));
setTranslationKey(ID);
setCreativeTab(ModCreativeTabs.DIMENSIONAL_DOORS_CREATIVE_TAB);

View file

@ -0,0 +1,11 @@
package org.dimdev.dimdoors.shared.fluids;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
public class FluidLiquid extends Fluid {
public FluidLiquid(String fluidName) {
super(fluidName, new ResourceLocation(String.format("dimdoors:blocks/%s_still", fluidName)), new ResourceLocation(String.format("dimdoors:blocks/%s_flow", fluidName)));
this.setUnlocalizedName(fluidName);
}
}

View file

@ -0,0 +1,19 @@
package org.dimdev.dimdoors.shared.fluids;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import org.dimdev.dimdoors.shared.blocks.BlockFabricEternal;
public class ModFluids {
public static final Fluid ETERNAL_FABRIC = new FluidLiquid(BlockFabricEternal.ID);
public static void registerFluids() {
registerFluid(ETERNAL_FABRIC);
}
public static void registerFluid(Fluid fluid)
{
FluidRegistry.registerFluid(fluid);
FluidRegistry.addBucketForFluid(fluid);
}
}

View file

@ -50,7 +50,6 @@ public final class ModItems {
public static final ItemColored FABRIC = (ItemColored) new ItemColored(ModBlocks.FABRIC, true).setSubtypeNames(new String[]{"white", "orange", "magenta", "lightBlue", "yellow", "lime", "pink", "gray", "silver", "cyan", "purple", "blue", "brown", "green", "red", "black"}).setRegistryName(ModBlocks.FABRIC.getRegistryName());
public static final ItemColored ANCIENT_FABRIC = (ItemColored) new ItemColored(ModBlocks.ANCIENT_FABRIC, true).setSubtypeNames(new String[]{"white", "orange", "magenta", "lightBlue", "yellow", "lime", "pink", "gray", "silver", "cyan", "purple", "blue", "brown", "green", "red", "black"}).setRegistryName(ModBlocks.ANCIENT_FABRIC.getRegistryName());
public static final ItemBlock UNRAVELLED_FABRIC = (ItemBlock) new ItemBlock(ModBlocks.UNRAVELLED_FABRIC).setRegistryName(ModBlocks.UNRAVELLED_FABRIC.getRegistryName());
public static final ItemBlock ETERNAL_FABRIC = (ItemBlock) new ItemBlock(ModBlocks.ETERNAL_FABRIC).setRegistryName(ModBlocks.ETERNAL_FABRIC.getRegistryName());
public static final ItemDimensionalTrapdoorWood WOOD_DIMENSIONAL_TRAPDOOR = new ItemDimensionalTrapdoorWood();
public static final ItemBlock MARKING_PLATE = (ItemBlock) new ItemBlock(ModBlocks.MARKING_PLATE).setRegistryName(ModBlocks.MARKING_PLATE.getRegistryName());
@ -82,7 +81,6 @@ public final class ModItems {
FABRIC,
ANCIENT_FABRIC,
UNRAVELLED_FABRIC,
ETERNAL_FABRIC,
WOOD_DIMENSIONAL_TRAPDOOR,
CREEPY_RECORD,
MARKING_PLATE);

View file

@ -11,7 +11,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.registries.GameData;
import net.minecraftforge.registries.RegistryManager;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.proxy.ServerProxy;
import org.dimdev.dimdoors.proxy.CommonProxy;
import org.dimdev.dimdoors.shared.blocks.ModBlocks;
public final class Initializer {
@ -25,7 +25,7 @@ public final class Initializer {
Loader.instance().setActiveModContainer(mc);
DimDoors.instance = new DimDoors();
DimDoors.proxy = new ServerProxy();
DimDoors.proxy = new CommonProxy();
DimDoors.instance.onPreInitialization(new FMLPreInitializationEvent());
ModBlocks.registerBlocks(new RegistryEvent.Register<Block>(GameData.BLOCKS, RegistryManager.ACTIVE.getRegistry(GameData.BLOCKS)));

View file

@ -70,7 +70,7 @@ public final class LimboDecay {
public static void applySpreadDecay(World world, BlockPos pos) {
//Check if we randomly apply decay spread or not. This can be used to moderate the frequency of
//full spread decay checks, which can also shift its performance impact on the game.
if (random.nextInt(MAX_DECAY_SPREAD_CHANCE) < DECAY_SPREAD_CHANCE) {
//if (random.nextInt(MAX_DECAY_SPREAD_CHANCE) < DECAY_SPREAD_CHANCE) {
//Apply decay to the blocks above, below, and on all four sides.
//World.getBlockId() implements bounds checking, so we don't have to worry about reaching out of the world
decayBlock(world, pos.up());
@ -79,7 +79,7 @@ public final class LimboDecay {
decayBlock(world, pos.south());
decayBlock(world, pos.west());
decayBlock(world, pos.east());
}
//}
}
/**
@ -136,17 +136,11 @@ public final class LimboDecay {
if (canDecayBlock(block, world, pos)) {
//Loop over the block IDs that decay can go through.
//Find an index matching the current blockID, if any.
if (block.isNormalCube()) {
if(getDecaySequence().containsKey(block)) {
IBlockState decay = getDecaySequence().get(block);
System.out.println(I18n.format(block.getBlock().getTranslationKey()) + " -> " + I18n.format(decay.getBlock().getTranslationKey()));
world.setBlockState(pos, decay);
} else {
return false;
}
} else {
if(getDecaySequence().containsKey(block)) {
IBlockState decay = getDecaySequence().get(block);
world.setBlockState(pos, decay);
} else if (!block.isNormalCube()) {
world.setBlockState(pos, AIR.getDefaultState());
}
return true;
@ -207,6 +201,9 @@ public final class LimboDecay {
stateConsumer.accept(
STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.ANDESITE_SMOOTH),
STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.ANDESITE));
stateConsumer.accept(
STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.ANDESITE),
STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.DIORITE));
stateConsumer.accept(
STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.DIORITE_SMOOTH),
STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.DIORITE));
@ -235,6 +232,7 @@ public final class LimboDecay {
STONEBRICK.getDefaultState(),
COBBLESTONE.getDefaultState());
blockConsumer.accept(REDSTONE_BLOCK, REDSTONE_ORE);
blockConsumer.accept(LIT_REDSTONE_ORE, STONE);
blockConsumer.accept(REDSTONE_ORE, STONE);
blockConsumer.accept(EMERALD_BLOCK, EMERALD_ORE);
blockConsumer.accept(EMERALD_ORE, STONE);

View file

@ -1,5 +1,9 @@
{
"forge_marker": 1,
"variants": {
"normal": { "model": "dimdoors:eternal_fabric" }
"fluid": {
"model": "forge:fluid",
"custom": { "fluid": "eternal_fabric" }
}
}
}
}

View file

@ -105,6 +105,8 @@ item.oak_dimensional_door.info=Place on the block under a rift \nto create a por
item.record.creepy.desc=Creepy - The sound of Limbo
fluid.eternal_fabric=Eternal Fabric
entity.dimdoors.monolith.name=Monolith
commands.dimteleport.usage=/dimteleport <dimension> <x> <y> <z> [yaw] [pitch]

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -0,0 +1,3 @@
{
"animation": { "frametime": 2 }
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -0,0 +1,3 @@
{
"animation": { "frametime": 2 }
}