mirror of
https://github.com/TeamMidnightDust/Decorative.git
synced 2025-12-15 12:35:10 +01:00
I'm a big fan
- Ceiling Fans are now working on Polymer!
This commit is contained in:
@@ -5,7 +5,10 @@ import eu.midnightdust.motschen.decorative.blockstates.CeilingFanStage;
|
||||
import eu.midnightdust.motschen.decorative.DecorativeMain;
|
||||
import eu.midnightdust.motschen.decorative.block.blockentity.CeilingFanBlockEntity;
|
||||
import eu.midnightdust.motschen.decorative.init.BlockEntities;
|
||||
import eu.midnightdust.motschen.decorative.polymer.model.ItemDisplayCeilingFanModel;
|
||||
import eu.midnightdust.motschen.decorative.polymer.model.ItemDisplayDigitalClockModel;
|
||||
import eu.pb4.factorytools.api.block.FactoryBlock;
|
||||
import eu.pb4.polymer.virtualentity.api.ElementHolder;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
@@ -19,6 +22,8 @@ import net.minecraft.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
@@ -94,5 +99,18 @@ public class CeilingFan extends BlockWithEntity implements BlockEntityProvider,
|
||||
public BlockState getPolymerBlockState(BlockState state) {
|
||||
return Blocks.BARRIER.getDefaultState();
|
||||
}
|
||||
@Override
|
||||
public BlockState getPolymerBreakEventBlockState(BlockState state, ServerPlayerEntity player) {
|
||||
return Blocks.WHITE_CONCRETE.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ElementHolder createElementHolder(ServerWorld world, BlockPos pos, BlockState initialBlockState) {
|
||||
return new ItemDisplayCeilingFanModel(initialBlockState);
|
||||
}
|
||||
@Override
|
||||
public boolean tickElementHolder(ServerWorld world, BlockPos pos, BlockState initialBlockState) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,16 +3,21 @@ package eu.midnightdust.motschen.decorative.blockstates;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
|
||||
public enum CeilingFanStage implements StringIdentifiable {
|
||||
OFF("off"),
|
||||
LEVEL_1("level1"),
|
||||
LEVEL_2("level2"),
|
||||
LEVEL_3("level3");
|
||||
OFF("off", 0),
|
||||
LEVEL_1("level1", 1),
|
||||
LEVEL_2("level2", 2),
|
||||
LEVEL_3("level3", 3);
|
||||
|
||||
private final String name;
|
||||
private final int speed;
|
||||
private static final CeilingFanStage[] vals = values();
|
||||
|
||||
CeilingFanStage(String name) {
|
||||
CeilingFanStage(String name, int speed) {
|
||||
this.name = name;
|
||||
this.speed = speed;
|
||||
}
|
||||
public int getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public CeilingFanStage next() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package eu.midnightdust.motschen.decorative.polymer;
|
||||
|
||||
import eu.midnightdust.motschen.decorative.polymer.model.ItemDisplayBirdBathModel;
|
||||
import eu.midnightdust.motschen.decorative.polymer.model.ItemDisplayCeilingFanModel;
|
||||
import eu.midnightdust.motschen.decorative.polymer.model.ItemDisplayChristmasLightsModel;
|
||||
import eu.midnightdust.motschen.decorative.polymer.model.ItemDisplayChristmasTreeModel;
|
||||
import eu.midnightdust.motschen.decorative.polymer.model.ItemDisplayDigitalClockModel;
|
||||
@@ -8,6 +9,7 @@ import eu.midnightdust.motschen.decorative.polymer.model.ItemDisplayDigitalClock
|
||||
public class PolymerSupport {
|
||||
public static void init() {
|
||||
ItemDisplayBirdBathModel.initModels();
|
||||
ItemDisplayCeilingFanModel.initModels();
|
||||
ItemDisplayChristmasLightsModel.initModels();
|
||||
ItemDisplayChristmasTreeModel.initModels();
|
||||
ItemDisplayDigitalClockModel.initModels();
|
||||
|
||||
@@ -1,4 +1,62 @@
|
||||
package eu.midnightdust.motschen.decorative.polymer.model;
|
||||
|
||||
public class ItemDisplayCeilingFanModel {
|
||||
import eu.midnightdust.motschen.decorative.DecorativeMain;
|
||||
import eu.midnightdust.motschen.decorative.config.DecorativeConfig;
|
||||
import eu.pb4.factorytools.api.resourcepack.BaseItemProvider;
|
||||
import eu.pb4.factorytools.api.virtualentity.BlockModel;
|
||||
import eu.pb4.factorytools.api.virtualentity.ItemDisplayElementUtil;
|
||||
import eu.pb4.polymer.virtualentity.api.attachment.BlockAwareAttachment;
|
||||
import eu.pb4.polymer.virtualentity.api.attachment.HolderAttachment;
|
||||
import eu.pb4.polymer.virtualentity.api.elements.ItemDisplayElement;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import static eu.midnightdust.motschen.decorative.DecorativeMain.id;
|
||||
|
||||
public class ItemDisplayCeilingFanModel extends BlockModel {
|
||||
private final ItemDisplayElement main;
|
||||
private final ItemDisplayElement blades;
|
||||
public static ItemStack MAIN;
|
||||
public static ItemStack BLADES;
|
||||
private int speed;
|
||||
private int rot;
|
||||
|
||||
public static void initModels() {
|
||||
MAIN = BaseItemProvider.requestModel(id("block/ceilingfan"));
|
||||
BLADES = BaseItemProvider.requestModel(id("block/polymer/ceilingfan_blades"));
|
||||
}
|
||||
|
||||
public ItemDisplayCeilingFanModel(BlockState state) {
|
||||
this.main = ItemDisplayElementUtil.createSimple(MAIN);
|
||||
this.main.setDisplaySize(1, 1);
|
||||
this.main.setScale(new Vector3f(2));
|
||||
this.main.setViewRange(0.75f * (DecorativeConfig.viewDistance / 100f));
|
||||
this.addElement(this.main);
|
||||
|
||||
this.blades = ItemDisplayElementUtil.createSimple(BLADES);
|
||||
this.blades.setDisplaySize(1, 1);
|
||||
this.blades.setScale(new Vector3f(2));
|
||||
this.blades.setViewRange(0.75f * (DecorativeConfig.viewDistance / 100f));
|
||||
this.addElement(this.blades);
|
||||
this.speed = state.get(DecorativeMain.STAGE).getSpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUpdate(HolderAttachment.UpdateType updateType) {
|
||||
if (updateType == BlockAwareAttachment.BLOCK_STATE_UPDATE) {
|
||||
var state = this.blockState();
|
||||
this.speed = state.get(DecorativeMain.STAGE).getSpeed();
|
||||
|
||||
this.tick();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onTick() {
|
||||
if (this.speed > 0) this.rot = this.rot + 2 + (4*this.speed);
|
||||
this.blades.setRightRotation(RotationAxis.POSITIVE_Y.rotationDegrees(this.rot));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ItemDisplayDigitalClockModel extends BlockModel {
|
||||
this.main.setDisplaySize(1, 1);
|
||||
this.main.setScale(new Vector3f(2));
|
||||
this.main.setRightRotation(RotationAxis.POSITIVE_Y.rotationDegrees(getRotation(state)));
|
||||
this.main.setViewRange(0.75f * (DecorativeConfig.viewDistance / 100f));
|
||||
this.main.setViewRange((DecorativeConfig.viewDistance / 100f));
|
||||
this.addElement(this.main);
|
||||
this.text = new TextDisplayElement(Text.of(getTime()));
|
||||
this.text.setDisplaySize(1, 1);
|
||||
@@ -50,6 +50,7 @@ public class ItemDisplayDigitalClockModel extends BlockModel {
|
||||
var offset = getOffset(state);
|
||||
this.text.setOffset(new Vec3d(offset.getLeft(), -0.4d, offset.getRight()));
|
||||
this.text.setRightRotation(RotationAxis.POSITIVE_Y.rotationDegrees(getRotation(state)));
|
||||
this.text.setViewRange(0.75f * (DecorativeConfig.viewDistance / 100f));
|
||||
this.text.setBackground(0x0000000);
|
||||
this.text.setShadow(true);
|
||||
this.addElement(this.text);
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"credit": "made by Motschen",
|
||||
"parent": "block/block",
|
||||
"textures": {
|
||||
"3": "decorative:block/ceilingfan",
|
||||
"5": "block/black_wool",
|
||||
"particle": "decorative:block/ceilingfan"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [7, 4, 7],
|
||||
"to": [9, 6, 9],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 2, 2], "texture": "#5"},
|
||||
"east": {"uv": [0, 0, 2, 2], "texture": "#5"},
|
||||
"south": {"uv": [0, 0, 2, 2], "texture": "#5"},
|
||||
"west": {"uv": [0, 0, 2, 2], "texture": "#5"},
|
||||
"down": {"uv": [0, 0, 2, 2], "texture": "#5"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [-3, 5, 7],
|
||||
"to": [7, 6, 9],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"east": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"south": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"west": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"up": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"down": {"uv": [0, 0, 4, 4], "texture": "#3"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [9, 5, 7],
|
||||
"to": [19, 6, 9],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"east": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"south": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"west": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"up": {"uv": [0, 0, 4, 4], "texture": "#3"},
|
||||
"down": {"uv": [0, 0, 4, 4], "texture": "#3"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [7, 5, -3],
|
||||
"to": [9, 6, 7],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"},
|
||||
"east": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"},
|
||||
"south": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"},
|
||||
"west": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"},
|
||||
"up": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"},
|
||||
"down": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [7, 5, 9],
|
||||
"to": [9, 6, 19],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"},
|
||||
"east": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"},
|
||||
"south": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"},
|
||||
"west": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"},
|
||||
"up": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"},
|
||||
"down": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#3"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user