mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 02:55:17 +00:00
Update to 1.15
Due to the massive rendering changes, certain features, such as emissive item rendering and the forge block rendering/lighting pipeline are currently disabled. Co-authored-by: David Quintana <[email protected]> Co-authored-by: tterrag <[email protected]> Co-authored-by: Unnoen <[email protected]>
This commit is contained in:
1 parent
9e5ecaaf75
commit
1933d05e36
565 files changed
+11114
-13142
No files matched your search
@@ -47,10 +47,10 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
/*
|
||||
@Mod(CustomTNTTest.MODID)
|
||||
@Mod.EventBusSubscriber(modid = CustomTNTTest.MODID, bus = Bus.MOD)
|
||||
public class CustomTNTTest {
|
||||
|
||||
static final String MODID = "custom_tnt_test";
|
||||
static final String BLOCK_ID = "test_tnt";
|
||||
|
||||
@@ -94,14 +94,14 @@ public class CustomTNTTest {
|
||||
if (!world.isRemote) {
|
||||
TNTEntity tnt = new CustomTNTEntity(world, pos.getX() + 0.5F, pos.getY(), pos.getZ() + 0.5F, igniter);
|
||||
world.addEntity(tnt);
|
||||
world.playSound(null, tnt.posX, tnt.posY, tnt.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.playSound(null, tnt.func_226277_ct_(), tnt.func_226278_cu_(), tnt.func_226281_cx_(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom TNT Entity that has a fuse of a quarter length, and four times the explosion strength
|
||||
*/
|
||||
*//*
|
||||
public static class CustomTNTEntity extends TNTEntity {
|
||||
|
||||
public CustomTNTEntity(EntityType<CustomTNTEntity> type, World world) {
|
||||
@@ -122,7 +122,7 @@ public class CustomTNTTest {
|
||||
|
||||
@Override
|
||||
protected void explode() {
|
||||
this.world.createExplosion(this, this.posX, this.posY, this.posZ, 16.0F, Explosion.Mode.BREAK);
|
||||
this.world.createExplosion(this, this.func_226277_ct_(), this.func_226278_cu_(), this.func_226281_cx_(), 16.0F, Explosion.Mode.BREAK);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -131,4 +131,5 @@ public class CustomTNTTest {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ public class FarmlandTrampleEventTest
|
||||
@SubscribeEvent
|
||||
public static void onFarmlandTrampled(BlockEvent.FarmlandTrampleEvent event)
|
||||
{
|
||||
if(event.getEntity().isSneaking())
|
||||
if(event.getEntity().isCrouching())
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ package net.minecraftforge.debug.block;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.pathfinding.PathNodeType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
@@ -31,8 +30,6 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod(PathNodeTypeTest.MOD_ID)
|
||||
@Mod.EventBusSubscriber
|
||||
public class PathNodeTypeTest
|
||||
@@ -44,20 +41,20 @@ public class PathNodeTypeTest
|
||||
@ObjectHolder(BLOCK_ID)
|
||||
private static Block TEST_BLOCK = null;
|
||||
|
||||
/*TODO
|
||||
@SubscribeEvent
|
||||
public static void register(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
event.getRegistry().register((new Block(Block.Properties.create(Material.ROCK))
|
||||
{
|
||||
@Override
|
||||
public PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos, @Nullable MobEntity entity)
|
||||
public PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos)
|
||||
{
|
||||
return PathNodeType.DOOR_OPEN;
|
||||
}
|
||||
}).setRegistryName(MOD_ID, BLOCK_ID));
|
||||
}
|
||||
|
||||
/*
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = MOD_ID)
|
||||
public static class ClientEventHandler
|
||||
{
|
||||
|
||||
@@ -25,8 +25,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.PistonBlock;
|
||||
import net.minecraft.block.PistonBlockStructureHelper;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.PistonBlockStructureHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
|
||||
@@ -1,81 +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.function.Function;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.BasicState;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod(BlockstateRetextureTest.MODID)
|
||||
public class BlockstateRetextureTest
|
||||
{
|
||||
public static final String MODID = "forge_blockstate_retexture_test";
|
||||
static final boolean ENABLED = true;
|
||||
|
||||
private static ResourceLocation fenceName = new ResourceLocation("minecraft", "oak_fence");
|
||||
private static ModelResourceLocation fenceLocation = new ModelResourceLocation(fenceName, "east=true,north=false,south=false,waterlogged=false,west=true");
|
||||
private static ResourceLocation stoneName = new ResourceLocation("minecraft", "stone");
|
||||
private static ModelResourceLocation stoneLocation = new ModelResourceLocation(stoneName, "");
|
||||
|
||||
private static Function<ResourceLocation, TextureAtlasSprite> textureGetter = location ->
|
||||
{
|
||||
assert location != null;
|
||||
return Minecraft.getInstance().getTextureMap().getAtlasSprite(location.toString());
|
||||
};
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MODID, value = Dist.CLIENT)
|
||||
public static class ClientEvents
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void onModelBakeEvent(ModelBakeEvent event)
|
||||
{
|
||||
if (!ENABLED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IModel<?> fence = ModelLoaderRegistry.getModelOrLogError(fenceLocation, "Error loading fence model");
|
||||
IModel<?> stone = ModelLoaderRegistry.getModelOrLogError(stoneLocation, "Error loading stone model");
|
||||
IModel<?> retexturedFence = fence.retexture(ImmutableMap.of("texture", "blocks/log_oak"));
|
||||
IModel<?> retexturedStone = stone.retexture(ImmutableMap.of("all", "blocks/diamond_block"));
|
||||
|
||||
IBakedModel fenceResult = retexturedFence.bake(event.getModelLoader(), textureGetter, new BasicState(fence.getDefaultState(), true), DefaultVertexFormats.ITEM);
|
||||
IBakedModel stoneResult = retexturedStone.bake(event.getModelLoader(), textureGetter, new BasicState(stone.getDefaultState(), true), DefaultVertexFormats.ITEM);
|
||||
|
||||
event.getModelRegistry().put(fenceLocation, fenceResult);
|
||||
event.getModelRegistry().put(stoneLocation, ModelLoaderRegistry.getMissingModel().bake(event.getModelLoader(), textureGetter, new BasicState(TRSRTransformation.identity(), false), DefaultVertexFormats.ITEM));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.model;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.WallBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
@Mod(ForgeBlockStatesLoaderTest.MODID)
|
||||
@Mod.EventBusSubscriber(modid = ForgeBlockStatesLoaderTest.MODID, bus= Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ForgeBlockStatesLoaderTest
|
||||
{
|
||||
public static final String MODID = "forgeblockstatesloader";
|
||||
|
||||
@ObjectHolder(MODID)
|
||||
public static class BLOCKS
|
||||
{
|
||||
public static final WallBlock custom_wall = null;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
event.getRegistry().registerAll(
|
||||
new WallBlock(Block.Properties.create(Material.ROCK))
|
||||
.setRegistryName(MODID, "custom_wall")
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().registerAll(
|
||||
new BlockItem(BLOCKS.custom_wall, new Item.Properties().group(ItemGroup.DECORATIONS)).setRegistryName(BLOCKS.custom_wall.getRegistryName())
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ 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.IEnviromentBlockReader;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.ModelDataManager;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
@@ -127,7 +127,7 @@ public class ModelDataTest
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IModelData getModelData(@Nonnull IEnviromentBlockReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
{
|
||||
if (world.getBlockState(pos.down()).getBlock() == Blocks.AIR)
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@ 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.IModelPart;
|
||||
import net.minecraftforge.common.model.Object;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.Models;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
@@ -370,10 +370,10 @@ public class ModelLoaderRegistryTest
|
||||
private final List<String> hidden = new ArrayList<String>();
|
||||
private final IModelState state = new IModelState()
|
||||
{
|
||||
private final Optional<TRSRTransformation> value = Optional.of(TRSRTransformation.identity());
|
||||
private final Optional<TRSRTransformation> value = Optional.of(TransformationMatrix.func_227983_a_());
|
||||
|
||||
@Override
|
||||
public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> part)
|
||||
public Optional<TRSRTransformation> apply(Optional<? extends Object> part)
|
||||
{
|
||||
if (part.isPresent())
|
||||
{
|
||||
@@ -796,7 +796,7 @@ public class ModelLoaderRegistryTest
|
||||
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJDynamicEyeTileEntity)
|
||||
{
|
||||
OBJDynamicEyeTileEntity te = (OBJDynamicEyeTileEntity) world.getTileEntity(pos);
|
||||
if (te.transform != TRSRTransformation.identity())
|
||||
if (te.transform != TransformationMatrix.func_227983_a_())
|
||||
{
|
||||
return ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, te.transform);
|
||||
}
|
||||
@@ -813,7 +813,7 @@ public class ModelLoaderRegistryTest
|
||||
super(null); // TODO
|
||||
}
|
||||
|
||||
private TRSRTransformation transform = TRSRTransformation.identity();
|
||||
private TRSRTransformation transform = TransformationMatrix.func_227983_a_();
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.NonNullLazy;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@Mod(NewModelLoaderTest.MODID)
|
||||
public class NewModelLoaderTest
|
||||
{
|
||||
public static final String MODID = "new_model_loader_test";
|
||||
public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID);
|
||||
public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Item> obj_item = ITEMS.register("obj_item", () ->
|
||||
new Item(new Item.Properties().group(ItemGroup.MISC)) {
|
||||
@Override
|
||||
public boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity)
|
||||
{
|
||||
return armorType == EquipmentSlotType.HEAD;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static RegistryObject<Item> custom_transforms = ITEMS.register("custom_transforms", () ->
|
||||
new Item(new Item.Properties().group(ItemGroup.MISC))
|
||||
);
|
||||
|
||||
public static RegistryObject<Item> custom_vanilla_loader = ITEMS.register("custom_vanilla_loader", () ->
|
||||
new Item(new Item.Properties().group(ItemGroup.MISC))
|
||||
);
|
||||
|
||||
public NewModelLoaderTest()
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
|
||||
BLOCKS.register(modEventBus);
|
||||
ITEMS.register(modEventBus);
|
||||
|
||||
/*DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
|
||||
MinecraftForge.EVENT_BUS.addListener(this::renderGuiOverlay);
|
||||
});*/
|
||||
}
|
||||
|
||||
/*
|
||||
private NonNullLazy<IRenderable.Configured<?>> modelRenderer = NonNullLazy.of(() -> {
|
||||
OBJModel model = OBJLoader.INSTANCE.loadModel(new ResourceLocation("new_model_loader_test", "models/item/sugar_glider.obj"), false, false, true, false);
|
||||
return IRenderable.withParameter(model.bakeRenderable(ModelLoader.defaultTextureGetter()), null);
|
||||
});
|
||||
|
||||
private NonNullLazy<BakedModelRenderable> modelRenderer2 = NonNullLazy.of(() -> {
|
||||
return BakedModelRenderable.of(new ItemStack(Items.COAL));
|
||||
});
|
||||
|
||||
public void renderGuiOverlay(RenderGameOverlayEvent.Post event)
|
||||
{
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.ALL)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef(event.getWindow().getScaledWidth() / 2.0f, event.getWindow().getScaledHeight() / 2.0f, 200);
|
||||
RenderSystem.scalef(16,16,16);
|
||||
//mc.getItemRenderer().renderItemAndEffectIntoGUI(new ItemStack(Items.COAL),0,0);
|
||||
modelRenderer.get().render();
|
||||
RenderSystem.translatef(1,1,1);
|
||||
modelRenderer2.get().render(new BakedModelRenderable.Context().withPerspective(ItemCameraTransforms.TransformType.GUI).withStack(new ItemStack(Items.COAL)));
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class GravityAttributeTest
|
||||
for(LivingEntity liv : list)
|
||||
{
|
||||
IAttributeInstance grav = liv.getAttribute(LivingEntity.ENTITY_GRAVITY);
|
||||
boolean inPlains = liv.world.getBiome(liv.getPosition()).getCategory() == Category.PLAINS;
|
||||
boolean inPlains = liv.world.func_226691_t_(liv.getPosition()).getCategory() == Category.PLAINS;
|
||||
if (inPlains && !grav.hasModifier(REDUCED_GRAVITY))
|
||||
{
|
||||
logger.info("Granted low gravity to Entity: {}", liv);
|
||||
|
||||
@@ -1,9 +1,27 @@
|
||||
/*
|
||||
* 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.entity.player;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraftforge.event.entity.player.PlayerPickupXpEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerXpEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -23,13 +41,6 @@ public class PlayerXpEventTest
|
||||
logger.info("The PlayerXpEvent has been called!");
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerPickupXpOld(PlayerPickupXpEvent event)
|
||||
{
|
||||
if (!ENABLE) return;
|
||||
logger.info("The deprecated PlayerPickupXpEvent has been called!");
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerPickupXp(PlayerXpEvent.PickupXp event)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,8 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FlowingFluidBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.fluid.FlowingFluid;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
@@ -46,8 +47,8 @@ public class NewFluidTest
|
||||
{
|
||||
public static final String MODID = "new_fluid_test";
|
||||
|
||||
public static final ResourceLocation FLUID_STILL = new ResourceLocation("minecraft:block/brown_mushroom_block");
|
||||
public static final ResourceLocation FLUID_FLOWING = new ResourceLocation("minecraft:block/mushroom_stem");
|
||||
public static final Material FLUID_STILL = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation("minecraft:block/brown_mushroom_block"));
|
||||
public static final Material FLUID_FLOWING = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation("minecraft:block/mushroom_stem"));
|
||||
|
||||
public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID);
|
||||
public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID);
|
||||
@@ -61,7 +62,7 @@ public class NewFluidTest
|
||||
);
|
||||
|
||||
public static RegistryObject<FlowingFluidBlock> test_fluid_block = BLOCKS.register("test_fluid_block", () ->
|
||||
new FlowingFluidBlock(test_fluid, Block.Properties.create(Material.WATER).doesNotBlockMovement().hardnessAndResistance(100.0F).noDrops())
|
||||
new FlowingFluidBlock(test_fluid, Block.Properties.create(net.minecraft.block.material.Material.WATER).doesNotBlockMovement().hardnessAndResistance(100.0F).noDrops())
|
||||
);
|
||||
public static RegistryObject<Item> test_fluid_bucket = ITEMS.register("test_fluid_bucket", () ->
|
||||
new BucketItem(test_fluid, new Item.Properties().containerItem(Items.BUCKET).maxStackSize(1).group(ItemGroup.MISC))
|
||||
|
||||
@@ -1,70 +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.testmods;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.BasicState;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@Mod("testobjmodelmod")
|
||||
public class TestOBJModelMod {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public TestOBJModelMod() {
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
|
||||
}
|
||||
|
||||
private void doClientStuff(final FMLClientSetupEvent event) {
|
||||
OBJLoader.INSTANCE.addDomain("testobjmodelmod");
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class RegistryEvents {
|
||||
@SubscribeEvent
|
||||
public static void onModelBakeEvent(ModelBakeEvent event) {
|
||||
try {
|
||||
// Try to load an OBJ model (placed in src/main/resources/assets/examplemod/models/)
|
||||
IUnbakedModel model = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation("testobjmodelmod:sample_model.obj"));
|
||||
|
||||
if (model instanceof OBJModel) {
|
||||
// If loading OBJ model succeeds, bake the model and replace stick's model with the baked model
|
||||
IBakedModel bakedModel = model.bake(event.getModelLoader(), ModelLoader.defaultTextureGetter(), new BasicState(model.getDefaultState(), false), DefaultVertexFormats.ITEM);
|
||||
event.getModelRegistry().put(new ModelResourceLocation("stick", "inventory"), bakedModel);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user