mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +00:00
Remove dead test classes.
This commit is contained in:
1 parent
f24991f3bb
commit
0c0603dc91
133 files changed
-15903
No files matched your search
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
|
||||
*/
|
||||
/**
|
||||
* Test for {@link TextureStitchEvent.Pre}.
|
||||
*//*
|
||||
|
||||
//@Mod(modid = CustomTextureAtlasSpriteTest.MOD_ID, name = CustomTextureAtlasSpriteTest.NAME, version = "1.0", clientSideOnly = true)
|
||||
public class CustomTextureAtlasSpriteTest
|
||||
{
|
||||
static final String MOD_ID = "custom_sprite_test";
|
||||
static final String NAME = "Custom sprite test";
|
||||
private static Logger logger;
|
||||
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MOD_ID)
|
||||
public static class Registration
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
event.getRegistry().register(new Block(Material.WOOD).setRegistryName(MOD_ID, "custom_sprite_block").setCreativeTab(CreativeTabs.MISC));
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
logger = event.getModLog();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public void textureStitch(TextureStitchEvent.Pre event)
|
||||
{
|
||||
DelegateSprite bottom = DelegateSprite.make("bottom", new ResourceLocation("blocks/diamond_block"));
|
||||
DelegateSprite top = DelegateSprite.make("top", new ResourceLocation("blocks/tnt_side"));
|
||||
|
||||
TextureMap textureMap = event.getMap();
|
||||
textureMap.setTextureEntry(bottom);
|
||||
textureMap.setTextureEntry(top);
|
||||
}
|
||||
|
||||
static final class DelegateSprite extends TextureAtlasSprite
|
||||
{
|
||||
final ResourceLocation delegate;
|
||||
|
||||
private DelegateSprite(ResourceLocation loc, ResourceLocation delegate)
|
||||
{
|
||||
super(loc.toString());
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
static DelegateSprite make(String name, ResourceLocation delegate)
|
||||
{
|
||||
return new DelegateSprite(new ResourceLocation(MOD_ID, name), delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomLoader(@Nonnull IResourceManager manager, @Nonnull ResourceLocation location)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return ImmutableList.of(delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load(@Nonnull IResourceManager manager, @Nonnull ResourceLocation location, @Nonnull Function<ResourceLocation, TextureAtlasSprite> textureGetter)
|
||||
{
|
||||
final TextureAtlasSprite sprite = textureGetter.apply(delegate);
|
||||
width = sprite.getIconWidth();
|
||||
height = sprite.getIconHeight();
|
||||
final int[][] oldPixels = sprite.getFrameTextureData(0);
|
||||
final int[][] pixels = new int[Minecraft.getMinecraft().gameSettings.mipmapLevels + 1][];
|
||||
pixels[0] = new int[width * height];
|
||||
for (int p = 0; p < width * height; p++) {
|
||||
pixels[0][p] = oldPixels[0][p] >> 8;
|
||||
}
|
||||
this.clearFramesTextureData();
|
||||
this.framesTextureData.add(pixels);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
*/
|
||||
/**
|
||||
* Simple mod to test fov modifier.
|
||||
*//*
|
||||
|
||||
//@Mod(modid = "fovmodifiertest", name = "FOV Modifier Test", version = "0.0.0", clientSideOnly = true)
|
||||
public class FOVModifierEventTest
|
||||
{
|
||||
static final boolean ENABLED = false;
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
if (ENABLED)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void getFOVModifier(EntityViewRenderEvent.FOVModifier event)
|
||||
{
|
||||
if (event.getState().getMaterial() == Material.WATER)
|
||||
{
|
||||
event.setFOV(event.getFOV() / 60.0f * 50.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
//@Mod(modid = SearchableCreativeTabTest.MODID, name = "Debug Search Tab", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class SearchableCreativeTabTest
|
||||
{
|
||||
public static final String MODID = "debugsearchtab";
|
||||
static final boolean ENABLED = false;
|
||||
|
||||
public static final CreativeTabs SEARCH_TAB = !ENABLED ? null : new CreativeTabs(1, "searchtab")
|
||||
{
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public ItemStack getTabIconItem()
|
||||
{
|
||||
return new ItemStack(Items.TOTEM_OF_UNDYING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSearchBar()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void displayAllRelevantItems(NonNullList<ItemStack> items)
|
||||
{
|
||||
super.displayAllRelevantItems(items);
|
||||
items.add(new ItemStack(Blocks.BARRIER));
|
||||
items.add(new ItemStack(Blocks.COMMAND_BLOCK));
|
||||
items.add(new ItemStack(Blocks.CHAIN_COMMAND_BLOCK));
|
||||
items.add(new ItemStack(Blocks.REPEATING_COMMAND_BLOCK));
|
||||
}
|
||||
};
|
||||
}
|
||||
*/
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.gui;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.GuiContainerEvent;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
|
||||
//@EventBusSubscriber(Side.CLIENT)
|
||||
//@Mod(modid = "guicontainereventtest", name = "GuiContainer Event Tests!", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class ContainerDrawForegroundEventTest
|
||||
{
|
||||
static final boolean ENABLED = false;
|
||||
|
||||
@ObjectHolder("minecraft:stone")
|
||||
public static final Item STONE_ITEM = null;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onForegroundRender(GuiContainerEvent.DrawForeground event)
|
||||
{
|
||||
if (!ENABLED) return;
|
||||
|
||||
for (Slot slot : event.getGuiContainer().inventorySlots.inventorySlots)
|
||||
{
|
||||
if (slot.getStack().getItem() == STONE_ITEM)
|
||||
{
|
||||
GlStateManager.disableLighting();
|
||||
|
||||
GuiUtils.drawGradientRect(400, slot.xPos, slot.yPos, slot.xPos + 16, slot.yPos + 16, 0x80000000, 0x80000000);
|
||||
|
||||
GlStateManager.enableLighting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.gui;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
//@Mod(modid = TooltipColorEventTest.MODID, name = "Tooltip Color Test", version = "0.1", clientSideOnly = true)
|
||||
public class TooltipColorEventTest
|
||||
{
|
||||
public static final String MODID = "tooltipcolortest";
|
||||
|
||||
private static final boolean ENABLE = false;
|
||||
|
||||
public TooltipColorEventTest()
|
||||
{
|
||||
if (ENABLE)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getTooltipColor(RenderTooltipEvent.Color event)
|
||||
{
|
||||
if (event.getStack().getItem() == Items.APPLE)
|
||||
{
|
||||
event.setBackground(0xF0510404);
|
||||
event.setBorderStart(0xF0bc0909);
|
||||
event.setBorderEnd(0xF03f0f0f);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@@ -1,579 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.animation.Animation;
|
||||
import net.minecraftforge.client.model.animation.AnimationTESR;
|
||||
import net.minecraftforge.client.model.b3d.B3DLoader;
|
||||
import net.minecraftforge.client.model.pipeline.VertexLighterSmoothAo;
|
||||
import net.minecraftforge.common.animation.Event;
|
||||
import net.minecraftforge.common.animation.ITimeValue;
|
||||
import net.minecraftforge.common.animation.TimeValues.VariableValue;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.Mod.Instance;
|
||||
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
//@Mod(modid = AnimatedModelTest.MODID, name = "ForgeDebugModelAnimation", version = AnimatedModelTest.VERSION, acceptableRemoteVersions = "*")
|
||||
public class AnimatedModelTest
|
||||
{
|
||||
public static final String MODID = "forgedebugmodelanimation";
|
||||
public static final String VERSION = "0.0";
|
||||
|
||||
public static final String blockName = "test_animation_block";
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing");
|
||||
@ObjectHolder(blockName)
|
||||
public static final Block TEST_BLOCK = null;
|
||||
@ObjectHolder(blockName)
|
||||
public static final Item TEST_ITEM = null;
|
||||
|
||||
public static final String rotateBlockName = "rotatest";
|
||||
@ObjectHolder(rotateBlockName)
|
||||
public static final Block TEST_ROTATE_BLOCK = null;
|
||||
@ObjectHolder(rotateBlockName)
|
||||
public static final Item TEST_ROTATE_ITEM = null;
|
||||
|
||||
@Instance(MODID)
|
||||
public static AnimatedModelTest instance;
|
||||
|
||||
public static CommonProxy proxy;
|
||||
private static Logger logger;
|
||||
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID)
|
||||
public static class Registration
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
GameRegistry.registerTileEntity(Chest.class, MODID + ":" + "tile_" + blockName);
|
||||
GameRegistry.registerTileEntity(Spin.class, MODID + ":" + "tile_" + rotateBlockName);
|
||||
event.getRegistry().register(
|
||||
new Block(Material.WOOD)
|
||||
{
|
||||
{
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setUnlocalizedName(MODID + "." + blockName);
|
||||
setRegistryName(new ResourceLocation(MODID, blockName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtendedBlockState createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[]{FACING, Properties.StaticProperty}, new IUnlistedProperty[]{Properties.AnimationProperty});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||
{
|
||||
return this.getDefaultState().withProperty(FACING, EnumFacing.getDirectionFromEntityLiving(pos, placer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return getDefaultState().withProperty(FACING, EnumFacing.getFront(meta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return state.getValue(FACING).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state)
|
||||
{
|
||||
return new Chest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
return state.withProperty(Properties.StaticProperty, true);
|
||||
}
|
||||
|
||||
*/
|
||||
/*@Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if(te instanceof Chest && state instanceof IExtendedBlockState)
|
||||
{
|
||||
return ((Chest)te).getState((IExtendedBlockState)state);
|
||||
}
|
||||
return super.getExtendedState(state, world, pos);
|
||||
}*//*
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof Chest)
|
||||
{
|
||||
((Chest) te).click(player.isSneaking());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
event.getRegistry().register(new Block(Material.WOOD){
|
||||
{
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setUnlocalizedName(MODID + "." + rotateBlockName);
|
||||
setRegistryName(new ResourceLocation(MODID, rotateBlockName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtendedBlockState createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[]{ Properties.StaticProperty }, new IUnlistedProperty[]{ Properties.AnimationProperty });
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return state.withProperty(Properties.StaticProperty, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state) {
|
||||
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
return new Spin();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().register(
|
||||
new ItemBlock(TEST_BLOCK)
|
||||
{
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt)
|
||||
{
|
||||
return new ItemAnimationHolder();
|
||||
}
|
||||
}.setRegistryName(TEST_BLOCK.getRegistryName())
|
||||
);
|
||||
event.getRegistry().register(
|
||||
new ItemBlock(TEST_ROTATE_BLOCK) {
|
||||
|
||||
}.setRegistryName(TEST_ROTATE_BLOCK.getRegistryName())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class CommonProxy
|
||||
{
|
||||
@Nullable
|
||||
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters){ return null; };
|
||||
}
|
||||
|
||||
public static class ServerProxy extends CommonProxy {}
|
||||
|
||||
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
|
||||
public static class ClientProxy extends CommonProxy
|
||||
{
|
||||
|
||||
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters)
|
||||
{
|
||||
return ModelLoaderRegistry.loadASM(location, parameters);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
B3DLoader.INSTANCE.addDomain(MODID);
|
||||
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(TEST_ITEM.getRegistryName(), "inventory"));
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(Chest.class, new AnimationTESR<Chest>()
|
||||
{
|
||||
@Override
|
||||
public void handleEvents(Chest chest, float time, Iterable<Event> pastEvents)
|
||||
{
|
||||
chest.handleEvents(time, pastEvents);
|
||||
}
|
||||
});
|
||||
ModelLoader.setCustomModelResourceLocation(TEST_ROTATE_ITEM, 0, new ModelResourceLocation(TEST_ROTATE_ITEM.getRegistryName(), "inventory"));
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(Spin.class, new AnimationTESR<Spin>());
|
||||
String entityName = MODID + ":entity_chest";
|
||||
//EntityRegistry.registerGlobalEntityID(EntityChest.class, entityName, EntityRegistry.findGlobalUniqueEntityId());
|
||||
EntityRegistry.registerModEntity(new ResourceLocation(entityName), EntityChest.class, entityName, 0, AnimatedModelTest.instance, 64, 20, true, 0xFFAAAA00, 0xFFDDDD00);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityChest.class, new IRenderFactory<EntityChest>()
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
public Render<EntityChest> createRenderFor(RenderManager manager)
|
||||
{
|
||||
*/
|
||||
/*model = ModelLoaderRegistry.getModel(new ResourceLocation(ModelLoaderRegistryTest.MODID, "block/chest.b3d"));
|
||||
if(model instanceof IRetexturableModel)
|
||||
{
|
||||
model = ((IRetexturableModel)model).retexture(ImmutableMap.of("#chest", "entity/chest/normal"));
|
||||
}
|
||||
if(model instanceof IModelCustomData)
|
||||
{
|
||||
model = ((IModelCustomData)model).process(ImmutableMap.of("mesh", "[\"Base\", \"Lid\"]"));
|
||||
}*//*
|
||||
|
||||
ResourceLocation location = new ModelResourceLocation(new ResourceLocation(MODID, blockName), "entity");
|
||||
return new RenderLiving<EntityChest>(manager, new net.minecraftforge.client.model.animation.AnimationModelBase<EntityChest>(location, new VertexLighterSmoothAo(Minecraft.getMinecraft().getBlockColors()))
|
||||
{
|
||||
@Override
|
||||
public void handleEvents(EntityChest chest, float time, Iterable<Event> pastEvents)
|
||||
{
|
||||
chest.handleEvents(time, pastEvents);
|
||||
}
|
||||
}, 0.5f)
|
||||
{
|
||||
protected ResourceLocation getEntityTexture(EntityChest entity)
|
||||
{
|
||||
return TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static class ItemAnimationHolder implements ICapabilityProvider
|
||||
{
|
||||
private final VariableValue cycleLength = new VariableValue(4);
|
||||
|
||||
private final IAnimationStateMachine asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/engine.json"), ImmutableMap.<String, ITimeValue>of(
|
||||
"cycle_length", cycleLength
|
||||
));
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
return capability == CapabilityAnimation.ANIMATION_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||
{
|
||||
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
|
||||
{
|
||||
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
logger = event.getModLog();
|
||||
}
|
||||
|
||||
public static class Spin extends TileEntity
|
||||
{
|
||||
@Nullable
|
||||
private final IAnimationStateMachine asm;
|
||||
|
||||
public Spin()
|
||||
{
|
||||
asm = proxy.load(new ResourceLocation(MODID, "asms/block/rotatest.json"), ImmutableMap.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing side)
|
||||
{
|
||||
return capability == CapabilityAnimation.ANIMATION_CAPABILITY || super.hasCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing side)
|
||||
{
|
||||
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
|
||||
{
|
||||
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
|
||||
}
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFastRenderer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Chest extends TileEntity
|
||||
{
|
||||
@Nullable
|
||||
private final IAnimationStateMachine asm;
|
||||
private final VariableValue cycleLength = new VariableValue(4);
|
||||
private final VariableValue clickTime = new VariableValue(Float.NEGATIVE_INFINITY);
|
||||
//private final VariableValue offset = new VariableValue(0);
|
||||
|
||||
public Chest()
|
||||
{
|
||||
*/
|
||||
/*asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/chest.json"), ImmutableMap.<String, ITimeValue>of(
|
||||
"click_time", clickTime
|
||||
));*//*
|
||||
|
||||
asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/engine.json"), ImmutableMap.<String, ITimeValue>of(
|
||||
"cycle_length", cycleLength,
|
||||
"click_time", clickTime
|
||||
//"offset", offset
|
||||
));
|
||||
}
|
||||
|
||||
public void handleEvents(float time, Iterable<Event> pastEvents)
|
||||
{
|
||||
for (Event event : pastEvents)
|
||||
{
|
||||
logger.info("Event: {} {} {} {}", event.event(), event.offset(), getPos(), time);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFastRenderer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
*/
|
||||
/*public IExtendedBlockState getState(IExtendedBlockState state) {
|
||||
return state.withProperty(B3DFrameProperty.instance, curState);
|
||||
}*//*
|
||||
|
||||
|
||||
public void click(boolean sneaking)
|
||||
{
|
||||
if (asm != null)
|
||||
{
|
||||
if (sneaking)
|
||||
{
|
||||
cycleLength.setValue(6 - cycleLength.apply(0));
|
||||
}
|
||||
*/
|
||||
/*else if(asm.currentState().equals("closed"))
|
||||
{
|
||||
clickTime.setValue(Animation.getWorldTime(getWorld()));
|
||||
asm.transition("opening");
|
||||
}
|
||||
else if(asm.currentState().equals("open"))
|
||||
{
|
||||
clickTime.setValue(Animation.getWorldTime(getWorld()));
|
||||
asm.transition("closing");
|
||||
}*//*
|
||||
|
||||
else if (asm.currentState().equals("default"))
|
||||
{
|
||||
float time = Animation.getWorldTime(getWorld(), Animation.getPartialTickTime());
|
||||
clickTime.setValue(time);
|
||||
//offset.setValue(time);
|
||||
//asm.transition("moving");
|
||||
asm.transition("starting");
|
||||
}
|
||||
else if (asm.currentState().equals("moving"))
|
||||
{
|
||||
clickTime.setValue(Animation.getWorldTime(getWorld(), Animation.getPartialTickTime()));
|
||||
asm.transition("stopping");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing side)
|
||||
{
|
||||
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing side)
|
||||
{
|
||||
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
|
||||
{
|
||||
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
|
||||
}
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityChest extends EntityLiving
|
||||
{
|
||||
private final IAnimationStateMachine asm;
|
||||
private final VariableValue cycleLength = new VariableValue(getHealth() / 5);
|
||||
|
||||
public EntityChest(World world)
|
||||
{
|
||||
super(world);
|
||||
setSize(1, 1);
|
||||
asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/engine.json"), ImmutableMap.<String, ITimeValue>of(
|
||||
"cycle_length", cycleLength
|
||||
));
|
||||
}
|
||||
|
||||
public void handleEvents(float time, Iterable<Event> pastEvents)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityUpdate()
|
||||
{
|
||||
super.onEntityUpdate();
|
||||
if (world.isRemote && cycleLength != null)
|
||||
{
|
||||
cycleLength.setValue(getHealth() / 5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyEntityAttributes()
|
||||
{
|
||||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing side)
|
||||
{
|
||||
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing side)
|
||||
{
|
||||
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
|
||||
{
|
||||
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
|
||||
}
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
//@Mod(modid = ItemLayerModelTest.MODID, name = "ForgeDebugItemLayerModel", version = ItemLayerModelTest.VERSION, acceptableRemoteVersions = "*")
|
||||
public class ItemLayerModelTest
|
||||
{
|
||||
public static final String MODID = "forgedebugitemlayermodel";
|
||||
public static final String VERSION = "1.0";
|
||||
@ObjectHolder("test_item")
|
||||
public static final Item TEST_ITEM = null;
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID)
|
||||
public static class Registration
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registrItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().register(new TestItem());
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + TestItem.name, "inventory"));
|
||||
}
|
||||
}
|
||||
|
||||
public static final class TestItem extends Item
|
||||
{
|
||||
public static final String name = "test_item";
|
||||
|
||||
private TestItem()
|
||||
{
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setUnlocalizedName(MODID + ":" + name);
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("foo", new Random().nextInt());
|
||||
stack.setTagCompound(tag);
|
||||
stack.setStackDisplayName(String.valueOf(new Random().nextInt()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack)
|
||||
{
|
||||
return shouldCauseReequipAnimation(oldStack, newStack, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
oldStack = oldStack.copy();
|
||||
oldStack.setTagCompound(null);
|
||||
newStack = newStack.copy();
|
||||
newStack.setTagCompound(null);
|
||||
return !ItemStack.areItemStacksEqual(oldStack, newStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState)
|
||||
{
|
||||
// This tool is a super pickaxe if the player is wearing a helment
|
||||
if ("pickaxe".equals(toolClass) && player != null && !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty())
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
return super.getHarvestLevel(stack, toolClass, player, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, IBlockState state)
|
||||
{
|
||||
return 10f;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
//@Mod.EventBusSubscriber
|
||||
//@Mod(modid = ItemModelConflictTest.MODID, name = "Test mod for model conflicts", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class ItemModelConflictTest
|
||||
{
|
||||
public static final String MODID = "item_model_conflict_test";
|
||||
|
||||
@GameRegistry.ObjectHolder(MODID + ":item")
|
||||
public static final Item TEST_ITEM = null;
|
||||
|
||||
@GameRegistry.ObjectHolder(MODID + ":test")
|
||||
public static final Block TEST_BLOCK = null;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
event.getRegistry().register(
|
||||
new Block(Material.ROCK)
|
||||
.setRegistryName(MODID, "test")
|
||||
.setUnlocalizedName(MODID + ".test")
|
||||
.setCreativeTab(CreativeTabs.BUILDING_BLOCKS)
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().registerAll(
|
||||
new Item()
|
||||
.setRegistryName(MODID, "item")
|
||||
.setUnlocalizedName(MODID + ".item")
|
||||
.setCreativeTab(CreativeTabs.MISC),
|
||||
new ItemBlock(TEST_BLOCK)
|
||||
.setRegistryName(TEST_BLOCK.getRegistryName())
|
||||
);
|
||||
}
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID, value = Side.CLIENT)
|
||||
public static class ClientEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(TEST_BLOCK), 0, new ModelResourceLocation(TEST_BLOCK.getRegistryName(), "normal"));
|
||||
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(MODID + ":test", "inventory"));
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
//@Mod.EventBusSubscriber
|
||||
//@Mod(modid = ItemModelGenerationTest.MOD_ID, name = "Item model generation test", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class ItemModelGenerationTest
|
||||
{
|
||||
static final String MOD_ID = "item_model_generation_test";
|
||||
|
||||
@GameRegistry.ObjectHolder("animation_test")
|
||||
public static final Item ANIMATION_TEST = null;
|
||||
|
||||
@GameRegistry.ObjectHolder("intersection_test")
|
||||
public static final Item INTERSECTION_TEST = null;
|
||||
|
||||
@GameRegistry.ObjectHolder("opacity_test")
|
||||
public static final Item OPACITY_TEST = null;
|
||||
|
||||
@GameRegistry.ObjectHolder("overlap_test")
|
||||
public static final Item OVERLAP_TEST = null;
|
||||
|
||||
@GameRegistry.ObjectHolder("pattern_test")
|
||||
public static final Item PATTERN_TEST = null;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().registerAll(
|
||||
new Item()
|
||||
.setRegistryName("animation_test")
|
||||
.setUnlocalizedName(MOD_ID + ".animation_test")
|
||||
.setCreativeTab(CreativeTabs.MISC),
|
||||
new Item()
|
||||
.setRegistryName("intersection_test")
|
||||
.setUnlocalizedName(MOD_ID + ".intersection_test")
|
||||
.setCreativeTab(CreativeTabs.MISC),
|
||||
new Item()
|
||||
.setRegistryName("opacity_test")
|
||||
.setUnlocalizedName(MOD_ID + ".opacity_test")
|
||||
.setCreativeTab(CreativeTabs.MISC),
|
||||
new Item()
|
||||
.setRegistryName("overlap_test")
|
||||
.setUnlocalizedName(MOD_ID + ".overlap_test")
|
||||
.setCreativeTab(CreativeTabs.MISC),
|
||||
new Item()
|
||||
.setRegistryName("pattern_test")
|
||||
.setUnlocalizedName(MOD_ID + ".pattern_test")
|
||||
.setCreativeTab(CreativeTabs.MISC)
|
||||
);
|
||||
}
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MOD_ID, value = Side.CLIENT)
|
||||
public static class ClientEventHandler
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
setCustomMRL(ANIMATION_TEST);
|
||||
setCustomMRL(INTERSECTION_TEST);
|
||||
setCustomMRL(OPACITY_TEST);
|
||||
setCustomMRL(OVERLAP_TEST);
|
||||
setCustomMRL(PATTERN_TEST);
|
||||
}
|
||||
|
||||
private static void setCustomMRL(Item item)
|
||||
{
|
||||
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,394 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//@Mod(modid = ModelBakeEventTest.MODID, name = "ForgeDebugModelBakeEvent", version = ModelBakeEventTest.VERSION, acceptableRemoteVersions = "*")
|
||||
public class ModelBakeEventTest
|
||||
{
|
||||
public static final String MODID = "forgedebugmodelbakeevent";
|
||||
public static final String VERSION = "1.0";
|
||||
public static final int cubeSize = 3;
|
||||
|
||||
private static ResourceLocation blockName = new ResourceLocation(MODID, CustomModelBlock.name);
|
||||
private static ModelResourceLocation blockLocation = new ModelResourceLocation(blockName, "normal");
|
||||
private static ModelResourceLocation itemLocation = new ModelResourceLocation(blockName, "inventory");
|
||||
|
||||
@ObjectHolder(CustomModelBlock.name)
|
||||
public static final Block CUSTOM_BLOCK = null;
|
||||
@ObjectHolder(CustomModelBlock.name)
|
||||
public static final Block CUSTOM_ITEM = null;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final IUnlistedProperty<Integer>[] properties = new IUnlistedProperty[6];
|
||||
|
||||
static
|
||||
{
|
||||
for (EnumFacing f : EnumFacing.values())
|
||||
{
|
||||
properties[f.ordinal()] = Properties.toUnlisted(PropertyInteger.create(f.getName(), 0, (1 << (cubeSize * cubeSize)) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID)
|
||||
public static class Registration
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
event.getRegistry().register(new CustomModelBlock());
|
||||
GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity");
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().register(new ItemBlock(CUSTOM_BLOCK).setRegistryName(CUSTOM_BLOCK.getRegistryName()));
|
||||
}
|
||||
}
|
||||
|
||||
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
|
||||
public static class BakeEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
Item item = Item.getItemFromBlock(CUSTOM_BLOCK);
|
||||
ModelLoader.setCustomModelResourceLocation(item, 0, itemLocation);
|
||||
ModelLoader.setCustomStateMapper(CUSTOM_BLOCK, new StateMapperBase()
|
||||
{
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState p_178132_1_)
|
||||
{
|
||||
return blockLocation;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onModelBakeEvent(ModelBakeEvent event)
|
||||
{
|
||||
TextureAtlasSprite base = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/slime");
|
||||
TextureAtlasSprite overlay = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/redstone_block");
|
||||
IBakedModel customModel = new CustomModel(base, overlay);
|
||||
event.getModelRegistry().putObject(blockLocation, customModel);
|
||||
event.getModelRegistry().putObject(itemLocation, customModel);
|
||||
}
|
||||
|
||||
public static class CustomModel implements IBakedModel
|
||||
{
|
||||
private final TextureAtlasSprite base, overlay;
|
||||
//private boolean hasStateSet = false;
|
||||
|
||||
public CustomModel(TextureAtlasSprite base, TextureAtlasSprite overlay)
|
||||
{
|
||||
this.base = base;
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
// TODO update to builder
|
||||
private int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, float u, float v)
|
||||
{
|
||||
return new int[]{
|
||||
Float.floatToRawIntBits(x),
|
||||
Float.floatToRawIntBits(y),
|
||||
Float.floatToRawIntBits(z),
|
||||
color,
|
||||
Float.floatToRawIntBits(texture.getInterpolatedU(u)),
|
||||
Float.floatToRawIntBits(texture.getInterpolatedV(v)),
|
||||
0
|
||||
};
|
||||
}
|
||||
|
||||
private BakedQuad createSidedBakedQuad(float x1, float x2, float z1, float z2, float y, TextureAtlasSprite texture, EnumFacing side)
|
||||
{
|
||||
Vec3d v1 = rotate(new Vec3d(x1 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5);
|
||||
Vec3d v2 = rotate(new Vec3d(x1 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5);
|
||||
Vec3d v3 = rotate(new Vec3d(x2 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5);
|
||||
Vec3d v4 = rotate(new Vec3d(x2 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5);
|
||||
return new BakedQuad(Ints.concat(
|
||||
vertexToInts((float) v1.x, (float) v1.y, (float) v1.z, -1, texture, 0, 0),
|
||||
vertexToInts((float) v2.x, (float) v2.y, (float) v2.z, -1, texture, 0, 16),
|
||||
vertexToInts((float) v3.x, (float) v3.y, (float) v3.z, -1, texture, 16, 16),
|
||||
vertexToInts((float) v4.x, (float) v4.y, (float) v4.z, -1, texture, 16, 0)
|
||||
), -1, side, texture, true, DefaultVertexFormats.BLOCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
|
||||
{
|
||||
if (side != null)
|
||||
{
|
||||
return ImmutableList.of();
|
||||
}
|
||||
IExtendedBlockState exState = (IExtendedBlockState) state;
|
||||
int len = cubeSize * 5 + 1;
|
||||
List<BakedQuad> ret = new ArrayList<BakedQuad>();
|
||||
for (EnumFacing f : EnumFacing.values())
|
||||
{
|
||||
ret.add(createSidedBakedQuad(0, 1, 0, 1, 1, base, f));
|
||||
if (state != null)
|
||||
{
|
||||
for (int i = 0; i < cubeSize; i++)
|
||||
{
|
||||
for (int j = 0; j < cubeSize; j++)
|
||||
{
|
||||
Integer value = exState.getValue(properties[f.ordinal()]);
|
||||
if (value != null && (value & (1 << (i * cubeSize + j))) != 0)
|
||||
{
|
||||
ret.add(createSidedBakedQuad((float) (1 + i * 5) / len, (float) (5 + i * 5) / len, (float) (1 + j * 5) / len, (float) (5 + j * 5) / len, 1.0001f, overlay, f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return this.base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return ItemOverrideList.NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomModelBlock extends BlockContainer
|
||||
{
|
||||
public static final String name = "custom_model_block";
|
||||
|
||||
private CustomModelBlock()
|
||||
{
|
||||
super(Material.IRON);
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setUnlocalizedName(MODID + ":" + name);
|
||||
setRegistryName(blockName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state)
|
||||
{
|
||||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta)
|
||||
{
|
||||
return new CustomTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof CustomTileEntity)
|
||||
{
|
||||
CustomTileEntity cte = (CustomTileEntity) te;
|
||||
Vec3d vec = revRotate(new Vec3d(hitX - .5, hitY - .5, hitZ - .5), side).addVector(.5, .5, .5);
|
||||
IUnlistedProperty<Integer> property = properties[side.ordinal()];
|
||||
Integer value = cte.getState().getValue(property);
|
||||
if (value == null)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
value ^= (1 << (cubeSize * ((int) (vec.x * (cubeSize - .0001))) + ((int) (vec.z * (cubeSize - .0001)))));
|
||||
cte.setState(cte.getState().withProperty(property, value));
|
||||
world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof CustomTileEntity)
|
||||
{
|
||||
CustomTileEntity cte = (CustomTileEntity) te;
|
||||
return cte.getState();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[0], properties);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTileEntity extends TileEntity
|
||||
{
|
||||
private IExtendedBlockState state;
|
||||
|
||||
public CustomTileEntity()
|
||||
{
|
||||
}
|
||||
|
||||
public IExtendedBlockState getState()
|
||||
{
|
||||
if (state == null)
|
||||
{
|
||||
state = (IExtendedBlockState) getBlockType().getDefaultState();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(IExtendedBlockState state)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
private static Vec3d rotate(Vec3d vec, EnumFacing side)
|
||||
{
|
||||
switch (side)
|
||||
{
|
||||
case DOWN:
|
||||
return new Vec3d(vec.x, -vec.y, -vec.z);
|
||||
case UP:
|
||||
return new Vec3d(vec.x, vec.y, vec.z);
|
||||
case NORTH:
|
||||
return new Vec3d(vec.x, vec.z, -vec.y);
|
||||
case SOUTH:
|
||||
return new Vec3d(vec.x, -vec.z, vec.y);
|
||||
case WEST:
|
||||
return new Vec3d(-vec.y, vec.x, vec.z);
|
||||
case EAST:
|
||||
return new Vec3d(vec.y, -vec.x, vec.z);
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown Side " + side);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
private static Vec3d revRotate(Vec3d vec, EnumFacing side)
|
||||
{
|
||||
switch (side)
|
||||
{
|
||||
case DOWN:
|
||||
return new Vec3d(vec.x, -vec.y, -vec.z);
|
||||
case UP:
|
||||
return new Vec3d(vec.x, vec.y, vec.z);
|
||||
case NORTH:
|
||||
return new Vec3d(vec.x, -vec.z, vec.y);
|
||||
case SOUTH:
|
||||
return new Vec3d(vec.x, vec.z, -vec.y);
|
||||
case WEST:
|
||||
return new Vec3d(vec.y, -vec.x, vec.z);
|
||||
case EAST:
|
||||
return new Vec3d(-vec.y, vec.x, vec.z);
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown Side " + side);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,193 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ContainerBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.ModelDataManager;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
@Mod(ModelDataTest.MODID)
|
||||
public class ModelDataTest
|
||||
{
|
||||
public static final String MODID = "forgedebugmodeldata";
|
||||
public static final String VERSION = "1.0";
|
||||
|
||||
private static final ModelProperty<Boolean> MAGIC_PROP = new ModelProperty<Boolean>();
|
||||
private static final String BLOCK_NAME = "block";
|
||||
private static final String BLOCK_REGNAME = MODID + ":" + BLOCK_NAME;
|
||||
|
||||
@ObjectHolder(BLOCK_REGNAME)
|
||||
public static final Block MY_BLOCK = null;
|
||||
@ObjectHolder(BLOCK_REGNAME)
|
||||
public static final TileEntityType<Tile> TILE_TYPE = null;
|
||||
|
||||
public ModelDataTest()
|
||||
{
|
||||
final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
modEventBus.addGenericListener(Block.class, this::registerBlocks);
|
||||
modEventBus.addGenericListener(TileEntityType.class, this::registerTileEntities);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::modelBake);
|
||||
}
|
||||
|
||||
public void modelBake(ModelBakeEvent event)
|
||||
{
|
||||
final IBakedModel stone = event.getModelRegistry().get(new ModelResourceLocation("minecraft:stone"));
|
||||
final IBakedModel dirt = event.getModelRegistry().get(new ModelResourceLocation("minecraft:dirt"));
|
||||
event.getModelRegistry().put(new ModelResourceLocation(BLOCK_REGNAME, ""), new IDynamicBakedModel()
|
||||
{
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData)
|
||||
{
|
||||
return modelData.getData(MAGIC_PROP) ? stone.getQuads(state, side, rand, modelData) : dirt.getQuads(state, side, rand, modelData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return MissingTextureSprite.func_217790_a();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
{
|
||||
if (world.getBlockState(pos.down()).getBlock() == Blocks.AIR)
|
||||
{
|
||||
tileData.setData(MAGIC_PROP, !tileData.getData(MAGIC_PROP));
|
||||
}
|
||||
return tileData;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static class Tile extends TileEntity implements ITickableTileEntity
|
||||
{
|
||||
|
||||
public Tile()
|
||||
{
|
||||
super(TILE_TYPE);
|
||||
}
|
||||
|
||||
private int counter;
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (world.isRemote && counter++ == 100)
|
||||
{
|
||||
ModelDataManager.requestModelDataRefresh(this);
|
||||
world.markForRerender(getPos());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelData getModelData()
|
||||
{
|
||||
return new ModelDataMap.Builder().withInitial(MAGIC_PROP, counter < 100).build();
|
||||
}
|
||||
}
|
||||
|
||||
public void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
event.getRegistry().register(new ContainerBlock(Block.Properties.create(Material.ROCK))
|
||||
{
|
||||
@Override
|
||||
@Nullable
|
||||
public TileEntity createNewTileEntity(IBlockReader worldIn)
|
||||
{
|
||||
return new Tile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state)
|
||||
{
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
}.setRegistryName(MODID, BLOCK_NAME));
|
||||
}
|
||||
|
||||
public void registerTileEntities(RegistryEvent.Register<TileEntityType<?>> event)
|
||||
{
|
||||
event.getRegistry().register(TileEntityType.Builder.func_223042_a(Tile::new, MY_BLOCK).build(null).setRegistryName(MODID, BLOCK_NAME));
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,223 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.ForgeVersion;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fluids.BlockFluidClassic;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
|
||||
//@Mod(modid = ModelFluidTest.MODID, name = "ForgeDebugModelFluid", version = ModelFluidTest.VERSION, acceptableRemoteVersions = "*")
|
||||
public class ModelFluidTest
|
||||
{
|
||||
public static final String MODID = "forgedebugmodelfluid";
|
||||
public static final String VERSION = "1.0";
|
||||
|
||||
public static final boolean ENABLE = false;
|
||||
private static ModelResourceLocation fluidLocation = new ModelResourceLocation(MODID + ":" + TestFluidBlock.name, "fluid");
|
||||
private static ModelResourceLocation gasLocation = new ModelResourceLocation(MODID + ":" + TestFluidBlock.name, "gas");
|
||||
private static ModelResourceLocation milkLocation = new ModelResourceLocation(MODID + ":" + TestFluidBlock.name, "milk");
|
||||
@ObjectHolder(TestFluidBlock.name)
|
||||
public static final Block FLUID_BLOCK = null;
|
||||
@ObjectHolder(TestFluidBlock.name)
|
||||
public static final Item FLUID_ITEM = null;
|
||||
@ObjectHolder(TestGasBlock.name)
|
||||
public static final Block GAS_BLOCK = null;
|
||||
@ObjectHolder(TestGasBlock.name)
|
||||
public static final Item GAS_ITEM = null;
|
||||
@ObjectHolder(MilkFluidBlock.name)
|
||||
public static final Block MILK_BLOCK = null;
|
||||
@ObjectHolder(MilkFluidBlock.name)
|
||||
public static final Item MILK_ITEM = null;
|
||||
|
||||
//Used in DynBucketTest/FluidPlacementTest, TODO: Make this a full registry with @ObjectHolder?
|
||||
public static final Fluid MILK = new Fluid("milk", new ResourceLocation(ForgeVersion.MOD_ID, "blocks/milk_still"), new ResourceLocation(ForgeVersion.MOD_ID, "blocks/milk_flow"));
|
||||
public static final Fluid FLUID = new TestFluid();
|
||||
public static final Fluid GAS = new TestGas();
|
||||
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID)
|
||||
public static class Registration
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
if (!ENABLE)
|
||||
return;
|
||||
|
||||
//TODO: Make FluidRegistry a full registry?
|
||||
//Make a delegate system for FluidBlocks/Fluid Stacks?
|
||||
//Fluids must be registered before a FluidStack can be made. Which is done in the block constructor
|
||||
FluidRegistry.registerFluid(FLUID);
|
||||
FluidRegistry.registerFluid(GAS);
|
||||
FluidRegistry.registerFluid(MILK);
|
||||
event.getRegistry().registerAll(
|
||||
new TestFluidBlock(),
|
||||
new TestGasBlock(),
|
||||
new MilkFluidBlock()
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
if (!ENABLE)
|
||||
return;
|
||||
event.getRegistry().registerAll(
|
||||
new ItemBlock(FLUID_BLOCK).setRegistryName(FLUID_BLOCK.getRegistryName()),
|
||||
new ItemBlock(GAS_BLOCK).setRegistryName(GAS_BLOCK.getRegistryName()),
|
||||
new ItemBlock(MILK_BLOCK).setRegistryName(MILK_BLOCK.getRegistryName())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
|
||||
public static class ClientEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
if (!ENABLE)
|
||||
return;
|
||||
// no need to pass the locations here, since they'll be loaded by the block model logic.
|
||||
ModelBakery.registerItemVariants(FLUID_ITEM);
|
||||
ModelBakery.registerItemVariants(GAS_ITEM);
|
||||
ModelBakery.registerItemVariants(MILK_ITEM);
|
||||
ModelLoader.setCustomMeshDefinition(FLUID_ITEM, is -> fluidLocation);
|
||||
ModelLoader.setCustomMeshDefinition(GAS_ITEM, is -> gasLocation);
|
||||
ModelLoader.setCustomMeshDefinition(MILK_ITEM, is -> milkLocation);
|
||||
ModelLoader.setCustomStateMapper(FLUID_BLOCK, new StateMapperBase()
|
||||
{
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
|
||||
{
|
||||
return fluidLocation;
|
||||
}
|
||||
});
|
||||
ModelLoader.setCustomStateMapper(GAS_BLOCK, new StateMapperBase()
|
||||
{
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
|
||||
{
|
||||
return gasLocation;
|
||||
}
|
||||
});
|
||||
ModelLoader.setCustomStateMapper(MILK_BLOCK, new StateMapperBase()
|
||||
{
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
|
||||
{
|
||||
return milkLocation;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static final class TestFluid extends Fluid
|
||||
{
|
||||
public static final String name = "testfluid";
|
||||
|
||||
private TestFluid()
|
||||
{
|
||||
super(name, new ResourceLocation("blocks/water_still"), new ResourceLocation("blocks/water_flow"), new ResourceLocation("blocks/water_overlay"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor()
|
||||
{
|
||||
return 0xFF00FF00;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class TestGas extends Fluid
|
||||
{
|
||||
public static final String name = "testgas";
|
||||
|
||||
private TestGas()
|
||||
{
|
||||
super(name, new ResourceLocation("blocks/lava_still"), new ResourceLocation("blocks/lava_flow"));
|
||||
density = -1000;
|
||||
isGaseous = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor()
|
||||
{
|
||||
return 0xFFFF0000;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class TestFluidBlock extends BlockFluidClassic
|
||||
{
|
||||
public static final String name = "test_fluid_block";
|
||||
|
||||
private TestFluidBlock()
|
||||
{
|
||||
super(FLUID, Material.WATER);
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setUnlocalizedName(MODID + ":" + name);
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
}
|
||||
|
||||
public static final class MilkFluidBlock extends BlockFluidClassic
|
||||
{
|
||||
public static final String name = "milk_fluid_block";
|
||||
|
||||
private MilkFluidBlock()
|
||||
{
|
||||
super(MILK, Material.WATER);
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setUnlocalizedName(MODID + ":" + name);
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
}
|
||||
|
||||
public static final class TestGasBlock extends BlockFluidClassic
|
||||
{
|
||||
public static final String name = "test_gas_block";
|
||||
|
||||
private TestGasBlock()
|
||||
{
|
||||
super(GAS, Material.LAVA);
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setUnlocalizedName(MODID + ":" + name);
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,844 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.StateContainer.Builder;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.b3d.B3DLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.common.model.Object;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.Models;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
//@Mod(ModelLoaderRegistryTest.MODID)
|
||||
public class ModelLoaderRegistryTest
|
||||
{
|
||||
public static final boolean ENABLED = true;
|
||||
public static final String MODID = "forgedebugmodelloaderregistry";
|
||||
public static final String VERSION = "1.0";
|
||||
private static Logger logger;
|
||||
|
||||
//@ObjectHolder(CustomModelBlock.name)
|
||||
public static final Block CUSTOM_MODEL_BLOCK = null;
|
||||
//@ObjectHolder(OBJTesseractBlock.name)
|
||||
public static final Block TESSERACT_BLOCK = null;
|
||||
//@ObjectHolder(OBJVertexColoring1.name)
|
||||
public static final Block VERTEX_COLOR_1 = null;
|
||||
//@ObjectHolder(OBJVertexColoring2.name)
|
||||
public static final Block VERTEX_COLOR_2 = null;
|
||||
//@ObjectHolder(OBJDirectionBlock.name)
|
||||
public static final Block DIRECTION = null;
|
||||
//@ObjectHolder(OBJDirectionEye.name)
|
||||
public static final Block DIRECTION_EYE = null;
|
||||
//@ObjectHolder(OBJDynamicEye.name)
|
||||
public static final Block DYNAMIC_EYE = null;
|
||||
//@ObjectHolder(OBJCustomDataBlock.name)
|
||||
public static final Block CUSTOM_DATA = null;
|
||||
|
||||
//@ObjectHolder(OBJTesseractBlock.name)
|
||||
public static final TileEntityType<OBJTesseractTileEntity> TESSERACT_TILE = null;
|
||||
//@ObjectHolder(OBJVertexColoring2.name)
|
||||
public static final TileEntityType<OBJVertexColoring2TileEntity> VERTEX_COLOR_2_TILE = null;
|
||||
|
||||
public ModelLoaderRegistryTest()
|
||||
{
|
||||
if (!ENABLED)
|
||||
return;
|
||||
|
||||
logger = LogManager.getLogger();
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setupClient);
|
||||
}
|
||||
|
||||
private void setupClient(FMLClientSetupEvent event)
|
||||
{
|
||||
B3DLoader.INSTANCE.addDomain(MODID);
|
||||
OBJLoader.INSTANCE.addDomain(MODID);
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Bus.MOD)
|
||||
public static class Registration
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
if (!ENABLED)
|
||||
return;
|
||||
event.getRegistry().registerAll(
|
||||
new CustomModelBlock(),
|
||||
new OBJTesseractBlock(),
|
||||
new OBJVertexColoring1(),
|
||||
new OBJVertexColoring2(),
|
||||
new OBJDirectionBlock(),
|
||||
//new OBJDirectionEye(),
|
||||
//new OBJDynamicEye(),
|
||||
new OBJCustomDataBlock()
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerTileEntities(RegistryEvent.Register<TileEntityType<?>> event)
|
||||
{
|
||||
event.getRegistry().registerAll(
|
||||
new TileEntityType<>(OBJTesseractTileEntity::new, null).setRegistryName(OBJTesseractBlock.name),
|
||||
new TileEntityType<>(OBJVertexColoring2TileEntity::new, null).setRegistryName(OBJVertexColoring2.name));
|
||||
//GameRegistry.registerTileEntity(OBJDynamicEyeTileEntity.class, OBJDynamicEye.name);
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
if (!ENABLED)
|
||||
return;
|
||||
Block[] blocks = {
|
||||
CUSTOM_MODEL_BLOCK,
|
||||
TESSERACT_BLOCK,
|
||||
VERTEX_COLOR_1,
|
||||
VERTEX_COLOR_2,
|
||||
DIRECTION,
|
||||
//DIRECTION_EYE,
|
||||
//DYNAMIC_EYE,
|
||||
CUSTOM_DATA
|
||||
};
|
||||
for (Block block : blocks)
|
||||
event.getRegistry().register(new ItemBlock(block, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName(block.getRegistryName()));
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
if (!ENABLED)
|
||||
return;
|
||||
B3DLoader.INSTANCE.addDomain(MODID.toLowerCase());
|
||||
OBJLoader.INSTANCE.addDomain(MODID.toLowerCase());
|
||||
Block[] blocks = {
|
||||
CUSTOM_MODEL_BLOCK,
|
||||
TESSERACT_BLOCK,
|
||||
VERTEX_COLOR_1,
|
||||
VERTEX_COLOR_2,
|
||||
DIRECTION,
|
||||
//DIRECTION_EYE,
|
||||
//DYNAMIC_EYE,
|
||||
CUSTOM_DATA
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static final VoxelShape SHAPE = VoxelShapes.create(1/16D, 1/16D, 1/16D, 15/16D, 15/16D, 15/16D); // We don't really care, just not solid
|
||||
|
||||
public static class CustomModelBlock extends Block
|
||||
{
|
||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||
public static final String name = "custom_model_block";
|
||||
private int counter = 1;
|
||||
|
||||
private CustomModelBlock()
|
||||
{
|
||||
super(Properties.create(Material.IRON));
|
||||
this.setDefaultState(this.getStateContainer().getBaseState().with(FACING, EnumFacing.NORTH));
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
|
||||
{
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateForPlacement(BlockItemUseContext context)
|
||||
{
|
||||
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
*/
|
||||
/* @Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
//Only return an IExtendedBlockState from this method and createState(), otherwise block placement might break!
|
||||
B3DLoader.B3DState newState = new B3DLoader.B3DState(null, counter);
|
||||
return ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, newState);
|
||||
}
|
||||
*//*
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
logger.info("click {}", counter);
|
||||
if (player.isSneaking())
|
||||
{
|
||||
counter--;
|
||||
}
|
||||
else
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
//if(counter >= model.getNode().getKeys().size()) counter = 0;
|
||||
world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder)
|
||||
{
|
||||
builder.add(FACING);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* This block is intended to demonstrate how to change the visibility of a group(s)
|
||||
* from within the block's class.
|
||||
* By right clicking on this block the player increments an integer value in the tile entity
|
||||
* for this block, which is then added to a list of strings and passed into the constructor
|
||||
* for OBJState. NOTE: this trick only works if your groups are named '1', '2', '3', etc.,
|
||||
* otherwise they must be added by name.
|
||||
* Holding shift decrements the value in the tile entity.
|
||||
* @author shadekiller666
|
||||
*
|
||||
*//*
|
||||
|
||||
public static class OBJTesseractBlock extends Block
|
||||
{
|
||||
public static final String name = "obj_tesseract_block";
|
||||
|
||||
private OBJTesseractBlock()
|
||||
{
|
||||
super(Properties.create(Material.IRON));
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
|
||||
{
|
||||
return new OBJTesseractTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
|
||||
{
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (world.getTileEntity(pos) == null)
|
||||
{
|
||||
world.setTileEntity(pos, new OBJTesseractTileEntity());
|
||||
}
|
||||
OBJTesseractTileEntity tileEntity = (OBJTesseractTileEntity) world.getTileEntity(pos);
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
tileEntity.decrement();
|
||||
}
|
||||
else
|
||||
{
|
||||
tileEntity.increment();
|
||||
}
|
||||
|
||||
world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
*/
|
||||
/* @Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJTesseractTileEntity)
|
||||
{
|
||||
OBJTesseractTileEntity te = (OBJTesseractTileEntity) world.getTileEntity(pos);
|
||||
return ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, te.state);
|
||||
}
|
||||
return state;
|
||||
}*//*
|
||||
|
||||
}
|
||||
|
||||
public static class OBJTesseractTileEntity extends TileEntity
|
||||
{
|
||||
private int counter = 1;
|
||||
private int max = 32;
|
||||
private final List<String> hidden = new ArrayList<String>();
|
||||
private final IModelState state = new IModelState()
|
||||
{
|
||||
private final Optional<TRSRTransformation> value = Optional.of(TransformationMatrix.identity());
|
||||
|
||||
@Override
|
||||
public Optional<TRSRTransformation> apply(Optional<? extends Object> part)
|
||||
{
|
||||
if (part.isPresent())
|
||||
{
|
||||
// This whole thing is subject to change, but should do for now.
|
||||
UnmodifiableIterator<String> parts = Models.getParts(part.get());
|
||||
if (parts.hasNext())
|
||||
{
|
||||
String name = parts.next();
|
||||
// only interested in the root level
|
||||
if (!parts.hasNext() && hidden.contains(name))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
|
||||
public OBJTesseractTileEntity()
|
||||
{
|
||||
super(TESSERACT_TILE);
|
||||
}
|
||||
|
||||
public void increment()
|
||||
{
|
||||
if (this.counter == max)
|
||||
{
|
||||
this.counter = 0;
|
||||
this.hidden.clear();
|
||||
}
|
||||
this.counter++;
|
||||
this.hidden.add(Integer.toString(this.counter));
|
||||
TextComponentString text = new TextComponentString("" + this.counter);
|
||||
if (this.world.isRemote)
|
||||
{
|
||||
Minecraft.getInstance().ingameGUI.getChatGUI().printChatMessage(text);
|
||||
}
|
||||
}
|
||||
|
||||
public void decrement()
|
||||
{
|
||||
if (this.counter == 1)
|
||||
{
|
||||
this.counter = max + 1;
|
||||
for (int i = 1; i < max; i++) this.hidden.add(Integer.toString(i));
|
||||
}
|
||||
this.hidden.remove(Integer.toString(this.counter));
|
||||
this.counter--;
|
||||
TextComponentString text = new TextComponentString("" + this.counter);
|
||||
if (this.world.isRemote)
|
||||
{
|
||||
Minecraft.getInstance().ingameGUI.getChatGUI().printChatMessage(text);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMax(int max)
|
||||
{
|
||||
this.max = max;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* This block demonstrates how to utilize the vertex coloring feature
|
||||
* of the OBJ loader. See 'vertex_coloring.obj' and 'vertex_coloring.mtl' in
|
||||
* 'test/resources/assets/forgedebugmodelloaderregistry/models/block/', to properly
|
||||
* utilize this feature an obj file must have 1 'usemtl' key before every vertex as shown,
|
||||
* having less 'usemtl' lines than 'v' lines will result in the faces having that material's
|
||||
* color instead of each vertex.
|
||||
* @author shadekiller666
|
||||
*
|
||||
*//*
|
||||
|
||||
public static class OBJVertexColoring1 extends Block
|
||||
{
|
||||
public static final String name = "obj_vertex_coloring1";
|
||||
|
||||
private OBJVertexColoring1()
|
||||
{
|
||||
super(Properties.create(Material.IRON));
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
|
||||
{
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* This block demonstrates how to use IProperties and IUnlistedProperties together
|
||||
* in the same ExtendedBlockState. Similar to pistons, this block will face the player
|
||||
* when placed. Unlike pistons, however; this block's model is an eyeball, because
|
||||
* the OBJ loader can load spheres.
|
||||
* @author shadekiller666
|
||||
*
|
||||
*//*
|
||||
|
||||
public static class OBJDirectionEye extends Block
|
||||
{
|
||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||
public static final String name = "obj_direction_eye";
|
||||
|
||||
private OBJDirectionEye()
|
||||
{
|
||||
super(Properties.create(Material.IRON));
|
||||
setDefaultState(this.getStateContainer().getBaseState().with(FACING, EnumFacing.NORTH));
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateForPlacement(BlockItemUseContext context)
|
||||
{
|
||||
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder)
|
||||
{
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
|
||||
{
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* This block uses the same model as CustomModelBlock3 does, but
|
||||
* this class allows the player to cycle the colors of each vertex to black
|
||||
* and then back to the original color when right clicking on the block.
|
||||
* @author shadekiller666
|
||||
*
|
||||
*//*
|
||||
|
||||
public static class OBJVertexColoring2 extends Block
|
||||
{
|
||||
public static final String name = "obj_vertex_coloring2";
|
||||
|
||||
private OBJVertexColoring2()
|
||||
{
|
||||
super(Properties.create(Material.IRON));
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
|
||||
{
|
||||
return new OBJVertexColoring2TileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJVertexColoring2TileEntity)
|
||||
{
|
||||
((OBJVertexColoring2TileEntity) world.getTileEntity(pos)).cycleColors();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static class OBJVertexColoring2TileEntity extends TileEntity
|
||||
{
|
||||
private int index = 0;
|
||||
private int maxIndex = 1;
|
||||
private List<Vector4f> colorList = new ArrayList<Vector4f>();
|
||||
private boolean hasFilledList = false;
|
||||
private boolean shouldIncrement = true;
|
||||
|
||||
public OBJVertexColoring2TileEntity()
|
||||
{
|
||||
super(VERTEX_COLOR_2_TILE);
|
||||
}
|
||||
|
||||
public void cycleColors()
|
||||
{
|
||||
if (this.world.isRemote)
|
||||
{
|
||||
logger.info(shouldIncrement);
|
||||
*/
|
||||
/*
|
||||
IBakedModel bakedModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelFromBlockState(this.world.getBlockState(this.pos), this.world, this.pos);
|
||||
if (bakedModel != null && bakedModel instanceof OBJBakedModel)
|
||||
{
|
||||
OBJBakedModel objBaked = (OBJBakedModel) bakedModel;
|
||||
ImmutableList<String> materialNames = objBaked.getModel().getMatLib().getMaterialNames();
|
||||
if (!hasFilledList)
|
||||
{
|
||||
for (String name : materialNames)
|
||||
{
|
||||
if (!name.equals(OBJModel.Material.WHITE_NAME))
|
||||
{
|
||||
colorList.add(objBaked.getModel().getMatLib().getMaterial(name).getColor());
|
||||
}
|
||||
}
|
||||
hasFilledList = true;
|
||||
}
|
||||
maxIndex = materialNames.size();
|
||||
if (this.shouldIncrement && index + 1 < maxIndex)
|
||||
{
|
||||
FMLLog.info("incrementing");
|
||||
String name = materialNames.get(index);
|
||||
// no
|
||||
objBaked.getModel().getMatLib().changeMaterialColor(name, 0xFF000000);
|
||||
objBaked.scheduleRebake();
|
||||
index++;
|
||||
}
|
||||
else if (index - 1 >= 0)
|
||||
{
|
||||
index--;
|
||||
this.shouldIncrement = index == 0;
|
||||
int color = 0;
|
||||
color |= (int) (colorList.get(index).getW() * 255) << 24;
|
||||
color |= (int) (colorList.get(index).getX() * 255) << 16;
|
||||
color |= (int) (colorList.get(index).getY() * 255) << 8;
|
||||
color |= (int) (colorList.get(index).getZ() * 255);
|
||||
String name = materialNames.get(index);
|
||||
if (!name.equals(OBJModel.Material.WHITE_NAME))
|
||||
{
|
||||
// FIXME
|
||||
objBaked.getModel().getMatLib().changeMaterialColor(name, color);
|
||||
objBaked.scheduleRebake();
|
||||
}
|
||||
}
|
||||
this.world.markBlockRangeForRenderUpdate(this.pos, this.pos);
|
||||
}*//*
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* This block is a debug block that faces the player when placed, like a piston.
|
||||
* @author shadekiller666
|
||||
*
|
||||
*//*
|
||||
|
||||
public static class OBJDirectionBlock extends Block
|
||||
{
|
||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||
public static final String name = "obj_direction_block";
|
||||
|
||||
private OBJDirectionBlock()
|
||||
{
|
||||
super(Properties.create(Material.IRON));
|
||||
this.setDefaultState(this.getStateContainer().getBaseState().with(FACING, EnumFacing.NORTH));
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
|
||||
{
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateForPlacement(BlockItemUseContext context)
|
||||
{
|
||||
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder)
|
||||
{
|
||||
builder.add(FACING);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* This block is a testing block that will be used to test the use
|
||||
* of "custom" data defined in a forge blockstate json. WIP, ignore for now.
|
||||
* @author shadekiller666
|
||||
*
|
||||
*//*
|
||||
|
||||
public static class OBJCustomDataBlock extends Block
|
||||
{
|
||||
public static final BooleanProperty NORTH = BooleanProperty.create("north");
|
||||
public static final BooleanProperty SOUTH = BooleanProperty.create("south");
|
||||
public static final BooleanProperty WEST = BooleanProperty.create("west");
|
||||
public static final BooleanProperty EAST = BooleanProperty.create("east");
|
||||
public static final String name = "obj_custom_data_block";
|
||||
|
||||
private OBJCustomDataBlock()
|
||||
{
|
||||
super(Properties.create(Material.IRON));
|
||||
this.setDefaultState(this.getStateContainer().getBaseState().with(NORTH, false).with(SOUTH, false).with(WEST, false).with(EAST, false));
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
|
||||
{
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canConnectTo(IBlockReader world, BlockPos pos)
|
||||
{
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
return block instanceof OBJCustomDataBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState updatePostPlacement(IBlockState state, EnumFacing facing, IBlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos)
|
||||
{
|
||||
return state.with(NORTH, this.canConnectTo(world, pos.north())).with(SOUTH, this.canConnectTo(world, pos.south())).with(WEST, this.canConnectTo(world, pos.west())).with(EAST, this.canConnectTo(world, pos.east()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(Builder<Block, IBlockState> builder)
|
||||
{
|
||||
builder.add(NORTH, SOUTH, WEST, EAST);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* This block uses the same model as CustomModelBlock4, but instead of facing the
|
||||
* player when placed, this one ALWAYS faces the player. I know, creepy right?
|
||||
* @author shadekiller666
|
||||
*
|
||||
*//*
|
||||
|
||||
public static class OBJDynamicEye extends Block
|
||||
{
|
||||
public static final String name = "obj_dynamic_eye";
|
||||
|
||||
private OBJDynamicEye()
|
||||
{
|
||||
super(Properties.create(Material.IRON));
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
|
||||
{
|
||||
return new OBJDynamicEyeTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
|
||||
{
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
*/
|
||||
/* @Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJDynamicEyeTileEntity)
|
||||
{
|
||||
OBJDynamicEyeTileEntity te = (OBJDynamicEyeTileEntity) world.getTileEntity(pos);
|
||||
if (te.transform != TransformationMatrix.identity())
|
||||
{
|
||||
return ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, te.transform);
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}*//*
|
||||
|
||||
}
|
||||
|
||||
public static class OBJDynamicEyeTileEntity extends TileEntity implements ITickable
|
||||
{
|
||||
public OBJDynamicEyeTileEntity()
|
||||
{
|
||||
super(null); // TODO
|
||||
}
|
||||
|
||||
private TRSRTransformation transform = TransformationMatrix.identity();
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (this.world.isRemote)
|
||||
{
|
||||
Vector3d teLoc = new Vector3d(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
|
||||
EntityPlayer player = Minecraft.getInstance().player;
|
||||
Vector3d playerLoc = new Vector3d();
|
||||
playerLoc.setX(player.posX);
|
||||
playerLoc.setY(player.posY + player.getEyeHeight());
|
||||
playerLoc.setZ(player.posZ);
|
||||
Vector3d lookVec = new Vector3d(playerLoc.getX() - teLoc.getX(), playerLoc.getY() - teLoc.getY(), playerLoc.getZ() - teLoc.getZ());
|
||||
double angleYaw = Math.atan2(lookVec.getZ(), lookVec.getX()) - Math.PI / 2d;
|
||||
double anglePitch = Math.atan2(lookVec.getY(), Math.sqrt(lookVec.getX() * lookVec.getX() + lookVec.getZ() * lookVec.getZ()));
|
||||
AxisAngle4d yaw = new AxisAngle4d(0, 1, 0, -angleYaw);
|
||||
AxisAngle4d pitch = new AxisAngle4d(1, 0, 0, -anglePitch);
|
||||
Quat4f rot = new Quat4f(0, 0, 0, 1);
|
||||
Quat4f yawQuat = new Quat4f();
|
||||
Quat4f pitchQuat = new Quat4f();
|
||||
yawQuat.set(yaw);
|
||||
rot.mul(yawQuat);
|
||||
pitchQuat.set(pitch);
|
||||
rot.mul(pitchQuat);
|
||||
Matrix4f matrix = new Matrix4f();
|
||||
matrix.setIdentity();
|
||||
matrix.setRotation(rot);
|
||||
transform = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(matrix));
|
||||
this.world.markBlockRangeForRenderUpdate(this.pos, this.pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package net.minecraftforge.debug.client;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -1,271 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.rendering;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.animation.FastTESR;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
//@Mod(modid = FastTESRTransparentTest.MODID, name = "TransparentFastTESRTest", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class FastTESRTransparentTest
|
||||
{
|
||||
|
||||
static final String MODID = "transparent_fast_tesr_test";
|
||||
|
||||
private static class TransparentFastTESR extends FastTESR<TransparentFastTE>
|
||||
{
|
||||
|
||||
private static TextureAtlasSprite getFluidTexture(Fluid fluid)
|
||||
{
|
||||
final ResourceLocation textureLocation = fluid.getStill();
|
||||
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(textureLocation.toString());
|
||||
}
|
||||
|
||||
private static void addVertexWithUV(BufferBuilder wr, double x, double y, double z, double u, double v, int skyLight, int blockLight)
|
||||
{
|
||||
wr.pos(x, y, z).color(0xFF, 0xFF, 0xFF, 0xFF).tex(u, v).lightmap(skyLight, blockLight).endVertex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityFast(TransparentFastTE te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder wr)
|
||||
{
|
||||
if (te.fluid == null)
|
||||
return;
|
||||
final int skyLight = 0x00f0;
|
||||
final int blockLight = 0x00f0;
|
||||
|
||||
final TextureAtlasSprite texture = getFluidTexture(te.fluid);
|
||||
final double uMin = texture.getMinU();
|
||||
final double uMax = texture.getMaxU();
|
||||
final double vMin = texture.getMinV();
|
||||
final double vMax = texture.getMaxV();
|
||||
|
||||
wr.setTranslation(x, y, z);
|
||||
addVertexWithUV(wr, 1, 0, 0, uMax, vMin, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 1, 1, 0, uMax, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 1, 0, uMin, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 0, 0, uMin, vMin, skyLight, blockLight);
|
||||
|
||||
addVertexWithUV(wr, 1, 0, 1, uMin, vMin, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 1, 1, 1, uMin, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 1, 1, uMax, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 0, 1, uMax, vMin, skyLight, blockLight);
|
||||
|
||||
addVertexWithUV(wr, 1, 0, 0, uMin, vMin, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 1, 1, 0, uMin, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 1, 1, 1, uMax, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 1, 0, 1, uMax, vMin, skyLight, blockLight);
|
||||
|
||||
addVertexWithUV(wr, 0, 0, 1, uMin, vMin, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 1, 1, uMin, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 1, 0, uMax, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 0, 0, uMax, vMin, skyLight, blockLight);
|
||||
|
||||
addVertexWithUV(wr, 1, 0, 0, uMax, vMin, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 1, 0, 1, uMin, vMin, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 0, 1, uMin, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 0, 0, uMax, vMax, skyLight, blockLight);
|
||||
|
||||
addVertexWithUV(wr, 1, 1, 0, uMax, vMin, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 1, 0, uMax, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 0, 1, 1, uMin, vMax, skyLight, blockLight);
|
||||
addVertexWithUV(wr, 1, 1, 1, uMin, vMin, skyLight, blockLight);
|
||||
wr.setTranslation(0, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TransparentFastTE extends TileEntity
|
||||
{
|
||||
|
||||
private final Fluid fluid;
|
||||
|
||||
public TransparentFastTE()
|
||||
{
|
||||
this(null);
|
||||
}
|
||||
|
||||
public TransparentFastTE(Fluid fluid)
|
||||
{
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFastRenderer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass)
|
||||
{
|
||||
return pass == 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final PropertyInteger FLUID = PropertyInteger.create("fluid", 0, 15);
|
||||
|
||||
private static Optional<Fluid> getNthFluid(int meta)
|
||||
{
|
||||
return FluidRegistry.getRegisteredFluids().values().stream().skip(meta).findFirst();
|
||||
}
|
||||
|
||||
private static final Block testBlock = new BlockContainer(Material.CORAL)
|
||||
{
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||
{
|
||||
Optional<Fluid> maybeFluid = getNthFluid(meta);
|
||||
return maybeFluid.map(TransparentFastTE::new).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand)
|
||||
{
|
||||
final ItemStack held = placer.getHeldItem(hand);
|
||||
return getDefaultState().withProperty(FLUID, Math.min(held.getMetadata(), 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer(this, FLUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return state.getValue(FLUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return getDefaultState().withProperty(FLUID, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items)
|
||||
{
|
||||
final int fluidCount = Math.min(FluidRegistry.getRegisteredFluids().size(), 15);
|
||||
for (int i = 0; i < fluidCount; i++)
|
||||
items.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
};
|
||||
|
||||
//@EventBusSubscriber
|
||||
public static class BlockHolder
|
||||
{
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void onBlockRegister(RegistryEvent.Register<Block> evt)
|
||||
{
|
||||
evt.getRegistry().register(testBlock
|
||||
.setCreativeTab(CreativeTabs.DECORATIONS)
|
||||
.setRegistryName("fluid-tesr-block"));
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void onItemRegister(RegistryEvent.Register<Item> evt)
|
||||
{
|
||||
evt.getRegistry().register(new ItemBlock(testBlock)
|
||||
{
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn)
|
||||
{
|
||||
final Optional<Fluid> nthFluid = getNthFluid(stack.getMetadata());
|
||||
if (nthFluid.isPresent())
|
||||
{
|
||||
tooltip.add("Fluid: " + nthFluid.get().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
.setHasSubtypes(true)
|
||||
.setRegistryName("tesr-test"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent evt)
|
||||
{
|
||||
GameRegistry.registerTileEntity(TransparentFastTE.class, MODID + ":fast-tesr-te");
|
||||
}
|
||||
|
||||
//@EventBusSubscriber(value = Side.CLIENT, modid = MODID)
|
||||
public static class ClientLoader
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
ModelLoader.setCustomStateMapper(testBlock, block -> Collections.emptyMap());
|
||||
ModelBakery.registerItemVariants(Item.getItemFromBlock(testBlock));
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TransparentFastTE.class, new TransparentFastTESR());
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.rendering;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
//@Mod(modid = ItemTESRTest.MODID, name = "ForgeDebugItemTile", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class ItemTESRTest
|
||||
{
|
||||
public static final String MODID = "forgedebugitemtile";
|
||||
@ObjectHolder(TestBlock.name)
|
||||
public static final Block TEST_BLOCK = null;
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID)
|
||||
public static class Registration
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
event.getRegistry().register(new TestBlock());
|
||||
GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity");
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().register(new ItemBlock(TEST_BLOCK).setRegistryName(TEST_BLOCK.getRegistryName()));
|
||||
}
|
||||
}
|
||||
|
||||
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
|
||||
public static class BakeEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
final ModelResourceLocation itemLocation = new ModelResourceLocation(TEST_BLOCK.getRegistryName(), "normal");
|
||||
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(MODID, TestBlock.name));
|
||||
ForgeHooksClient.registerTESRItemStack(item, 0, CustomTileEntity.class);
|
||||
ModelLoader.setCustomModelResourceLocation(item, 0, itemLocation);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(CustomTileEntity.class, TestTESR.instance);
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void onModelBakeEvent(ModelBakeEvent event)
|
||||
{
|
||||
event.getModelManager().getBlockModelShapes().registerBuiltInBlocks(TEST_BLOCK);
|
||||
}
|
||||
|
||||
public static class TestTESR extends TileEntitySpecialRenderer<CustomTileEntity>
|
||||
{
|
||||
private static final TestTESR instance = new TestTESR();
|
||||
|
||||
private TestTESR()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(CustomTileEntity p_180535_1_, double x, double y, double z, float p_180535_8_, int p_180535_9_, float partial)
|
||||
{
|
||||
glPushMatrix();
|
||||
glTranslated(x, y, z);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.disableLighting();
|
||||
glColor4f(.2f, 1, .1f, 1);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(0, .5f, 0);
|
||||
glVertex3f(0, .5f, 1);
|
||||
glVertex3f(1, .5f, 1);
|
||||
glVertex3f(1, .5f, 0);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.enableLighting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class TestBlock extends BlockContainer
|
||||
{
|
||||
public static final String name = "custom_model_block";
|
||||
|
||||
private TestBlock()
|
||||
{
|
||||
super(Material.IRON);
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setUnlocalizedName(MODID + ":" + name);
|
||||
setRegistryName(new ResourceLocation(MODID, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta)
|
||||
{
|
||||
return new CustomTileEntity();
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTileEntity extends TileEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.rendering;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityArmorStand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.Mod.Instance;
|
||||
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
|
||||
//@Mod(modid = "wrnormal", name = "WRNormal", version = "1.0", acceptableRemoteVersions = "*")
|
||||
public class VertexBufferNormalTest
|
||||
{
|
||||
@Instance("wrnormal")
|
||||
public static VertexBufferNormalTest instance;
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLPreInitializationEvent event)
|
||||
{
|
||||
EntityRegistry.registerModEntity(new ResourceLocation("wrnormal", "scale_test"), EntityScaleTest.class, "scale_test", 0, instance, 60, 3, true);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, ()-> () -> RenderingRegistry.registerEntityRenderingHandler(EntityScaleTest.class, RenderScaleTest::new));
|
||||
}
|
||||
|
||||
public static class RenderScaleTestFactory implements IRenderFactory<EntityScaleTest>
|
||||
{
|
||||
@Override
|
||||
public RenderScaleTest createRenderFor(RenderManager manager)
|
||||
{
|
||||
return new RenderScaleTest(manager);
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityScaleTest extends EntityArmorStand
|
||||
{
|
||||
public EntityScaleTest(World world)
|
||||
{
|
||||
super(world);
|
||||
}
|
||||
}
|
||||
|
||||
public static class RenderScaleTest extends RenderLivingBase<EntityScaleTest>
|
||||
{
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("textures/blocks/stone.png");
|
||||
|
||||
public RenderScaleTest(RenderManager manager)
|
||||
{
|
||||
super(manager, new ModelScaleTest(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderName(EntityScaleTest entity, double x, double y, double z)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntityScaleTest entity)
|
||||
{
|
||||
return TEXTURE;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ModelScaleTest extends ModelBase
|
||||
{
|
||||
private ModelRenderer component;
|
||||
|
||||
public ModelScaleTest()
|
||||
{
|
||||
textureWidth = textureHeight = 16;
|
||||
component = new ModelRenderer(this);
|
||||
int size = 10;
|
||||
for (int x = 0; x < size; x++)
|
||||
{
|
||||
for (int z = 0; z < size; z++)
|
||||
{
|
||||
component.addBox((x - size / 2) * 3, 0, (z - size / 2) * 3, 2, 2, 2, -(x + z * size) / (float) (size * size) * 0.5F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Entity entity, float p1, float p2, float p3, float p4, float p5, float scale)
|
||||
{
|
||||
component.render(scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
Reference in new issue
Block a user