Skip to content

Commit b963bfb

Browse files
committed
Stop relying on TrackedData for lightning focus; begin working on Contactor
1 parent 688a20a commit b963bfb

13 files changed

Lines changed: 108 additions & 32 deletions

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ yarn_mappings=1.21.1+build.3
77
loader_version=0.16.10
88
fabric_version=0.115.1+1.21.1
99

10-
mod_version=1.0.0-alpha.19
10+
mod_version=1.0.0-alpha.20
1111
maven_group=falseresync.vivatech
1212
archives_base_name=vivatech
1313

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package falseresync.vivatech.common.block;
2+
3+
import com.mojang.serialization.MapCodec;
4+
import falseresync.vivatech.common.blockentity.ContactorBlockEntity;
5+
import net.minecraft.block.BlockRenderType;
6+
import net.minecraft.block.BlockState;
7+
import net.minecraft.block.BlockWithEntity;
8+
import net.minecraft.block.entity.BlockEntity;
9+
import net.minecraft.util.math.BlockPos;
10+
import org.jetbrains.annotations.Nullable;
11+
12+
public class ContactorBlock extends BlockWithEntity {
13+
public static final MapCodec<ContactorBlock> CODEC = createCodec(ContactorBlock::new);
14+
15+
protected ContactorBlock(Settings settings) {
16+
super(settings);
17+
}
18+
19+
@Override
20+
protected MapCodec<ContactorBlock> getCodec() {
21+
return CODEC;
22+
}
23+
24+
@Nullable
25+
@Override
26+
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
27+
return new ContactorBlockEntity(pos, state);
28+
}
29+
30+
@Override
31+
protected BlockRenderType getRenderType(BlockState state) {
32+
return BlockRenderType.MODEL;
33+
}
34+
}

src/main/java/falseresync/vivatech/common/block/VivatechBlocks.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ public class VivatechBlocks {
1616
public static final WindTurbineBlock WIND_TURBINE = r("wind_turbine", WindTurbineBlock::new, AbstractBlock.Settings.copy(Blocks.CAULDRON));
1717

1818
public static final HeaterBlock HEATER = r("heater", HeaterBlock::new, AbstractBlock.Settings.copy(Blocks.COPPER_BLOCK));
19-
public static final StaticCompensatorBlock STATIC_COMPENSATOR = r("static_compensator", StaticCompensatorBlock::new, AbstractBlock.Settings.copy(Blocks.COPPER_BLOCK));
2019
public static final ChargerBlock CHARGER = r("charger", ChargerBlock::new, AbstractBlock.Settings.copy(Blocks.COPPER_BLOCK));
2120

21+
public static final StaticCompensatorBlock STATIC_COMPENSATOR = r("static_compensator", StaticCompensatorBlock::new, AbstractBlock.Settings.copy(Blocks.COPPER_BLOCK));
22+
public static final StaticCompensatorBlock CONTACTOR = r("contactor", StaticCompensatorBlock::new, AbstractBlock.Settings.copy(Blocks.COPPER_BLOCK));
23+
2224
public static final WirePostBlock WIRE_POST = r("wire_post", WirePostBlock::new, AbstractBlock.Settings.copy(Blocks.LIGHTNING_ROD));
2325

2426
private static <T extends Block> T r(String id, Function<AbstractBlock.Settings, T> block, AbstractBlock.Settings settings) {

src/main/java/falseresync/vivatech/common/block/WirePostBlock.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ protected BlockState mirror(BlockState state, BlockMirror mirror) {
8282

8383
@Override
8484
public GridVertex getGridVertex(World world, BlockPos pos, BlockState state) {
85-
return new GridVertex(pos, PowerSystem.APPLIANCE.find(world, pos.offset(state.get(FACING)), null));
85+
var facing = state.get(FACING);
86+
return new GridVertex(pos, PowerSystem.APPLIANCE.find(world, pos.offset(facing), facing));
8687
}
8788

8889
@Override
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package falseresync.vivatech.common.blockentity;
2+
3+
import falseresync.vivatech.common.power.Appliance;
4+
import falseresync.vivatech.common.power.ApplianceProvider;
5+
import net.minecraft.block.BlockState;
6+
import net.minecraft.block.entity.BlockEntity;
7+
import net.minecraft.util.math.BlockPos;
8+
import net.minecraft.util.math.Direction;
9+
import org.jetbrains.annotations.Nullable;
10+
11+
public class ContactorBlockEntity extends BlockEntity implements ApplianceProvider {
12+
private final Appliance applianceA = new Appliance() {
13+
@Override
14+
public BlockPos getAppliancePos() {
15+
return null;
16+
}
17+
};
18+
19+
public ContactorBlockEntity(BlockPos pos, BlockState state) {
20+
super(VivatechBlockEntities.CONTACTOR, pos, state);
21+
}
22+
23+
@Override
24+
public Appliance getAppliance(@Nullable Direction side) {
25+
return null;
26+
}
27+
}

src/main/java/falseresync/vivatech/common/blockentity/VivatechBlockEntities.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ public class VivatechBlockEntities {
1212

1313
public static final @RegistryObject BlockEntityType<HeaterBlockEntity> HEATER =
1414
BlockEntityType.Builder.create(HeaterBlockEntity::new, VivatechBlocks.HEATER).build();
15-
public static final @RegistryObject BlockEntityType<StaticCompensatorBlockEntity> STATIC_COMPENSATOR =
16-
BlockEntityType.Builder.create(StaticCompensatorBlockEntity::new, VivatechBlocks.STATIC_COMPENSATOR).build();
1715
public static final @RegistryObject BlockEntityType<ChargerBlockEntity> CHARGER =
1816
BlockEntityType.Builder.create(ChargerBlockEntity::new, VivatechBlocks.CHARGER).build();
17+
18+
public static final @RegistryObject BlockEntityType<StaticCompensatorBlockEntity> STATIC_COMPENSATOR =
19+
BlockEntityType.Builder.create(StaticCompensatorBlockEntity::new, VivatechBlocks.STATIC_COMPENSATOR).build();
20+
public static final @RegistryObject BlockEntityType<ContactorBlockEntity> CONTACTOR =
21+
BlockEntityType.Builder.create(ContactorBlockEntity::new, VivatechBlocks.CONTACTOR).build();
1922
}

src/main/java/falseresync/vivatech/common/data/VivatechAttachments.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public class VivatechAttachments {
1212
public static final AttachmentType<Boolean> HAS_INSPECTOR_GOGGLES = AttachmentRegistry.create(
1313
vtId("has_inspector_goggles"),
1414
builder -> builder.syncWith(PacketCodecs.BOOL, AttachmentSyncPredicate.targetOnly()).persistent(Codec.BOOL));
15+
public static final AttachmentType<Boolean> THUNDERLESS_LIGHTNING = AttachmentRegistry.create(
16+
vtId("has_inspector_goggles"),
17+
builder -> builder.syncWith(PacketCodecs.BOOL, AttachmentSyncPredicate.all()));
1518
public static final AttachmentType<Integer> ENERGY_VEIL_NETWORK_ID = AttachmentRegistry.create(
1619
vtId("energy_veil_id"),
1720
builder -> builder.syncWith(PacketCodecs.INTEGER, AttachmentSyncPredicate.all()));

src/main/java/falseresync/vivatech/common/item/VivatechItemGroups.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ public class VivatechItemGroups {
1717
entries.add(VivatechItems.WIND_TURBINE);
1818

1919
entries.add(VivatechItems.HEATER);
20-
entries.add(VivatechItems.STATIC_COMPENSATOR);
2120
entries.add(VivatechItems.CHARGER);
2221

22+
entries.add(VivatechItems.STATIC_COMPENSATOR);
23+
entries.add(VivatechItems.CONTACTOR);
24+
2325
entries.add(VivatechItems.WIRE_POST);
2426

25-
entries.add(VivatechItems.MORTAR_AND_PESTLE);
2627
entries.add(VivatechItems.WIRE);
28+
entries.add(VivatechItems.MORTAR_AND_PESTLE);
2729
entries.add(VivatechItems.PLIERS);
2830
entries.add(VivatechItems.PROBE);
2931
entries.add(VivatechItems.INSPECTOR_GOGGLES);

src/main/java/falseresync/vivatech/common/item/VivatechItems.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ public class VivatechItems {
2222
public static final BlockItem WIND_TURBINE = rBlockItem("wind_turbine", VivatechBlocks.WIND_TURBINE, new Item.Settings());
2323

2424
public static final BlockItem HEATER = rBlockItem("heater", VivatechBlocks.HEATER, new Item.Settings());
25-
public static final BlockItem STATIC_COMPENSATOR = rBlockItem("static_compensator", VivatechBlocks.STATIC_COMPENSATOR, new Item.Settings());
2625
public static final BlockItem CHARGER = rBlockItem("charger", VivatechBlocks.CHARGER, new Item.Settings());
2726

27+
public static final BlockItem STATIC_COMPENSATOR = rBlockItem("static_compensator", VivatechBlocks.STATIC_COMPENSATOR, new Item.Settings());
28+
public static final BlockItem CONTACTOR = rBlockItem("contactor", VivatechBlocks.CONTACTOR, new Item.Settings());
29+
2830
public static final BlockItem WIRE_POST = rBlockItem("wire_post", VivatechBlocks.WIRE_POST, new Item.Settings());
2931

30-
public static final MortarAndPestleItem MORTAR_AND_PESTLE = r("mortar_and_pestle", MortarAndPestleItem::new, new Item.Settings().maxCount(1).maxDamage(16));
3132
public static final WireItem WIRE = r("wire", WireItem::new, new Item.Settings());
33+
public static final MortarAndPestleItem MORTAR_AND_PESTLE = r("mortar_and_pestle", MortarAndPestleItem::new, new Item.Settings().maxCount(1).maxDamage(16));
3234
public static final PliersItem PLIERS = r("pliers", PliersItem::new, new Item.Settings().maxCount(1));
3335
public static final ProbeItem PROBE = r("probe", ProbeItem::new, new Item.Settings().maxCount(1));
3436
public static final InspectorGogglesItem INSPECTOR_GOGGLES = r("inspector_goggles", InspectorGogglesItem::new, new Item.Settings().maxCount(1));

src/main/java/falseresync/vivatech/common/item/focus/LightningFocusItem.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import falseresync.vivatech.common.Vivatech;
44
import falseresync.vivatech.common.VivatechUtil;
5+
import falseresync.vivatech.common.data.VivatechAttachments;
56
import falseresync.vivatech.network.report.Reports;
67
import net.minecraft.entity.EntityType;
78
import net.minecraft.entity.EquipmentSlot;
@@ -36,7 +37,7 @@ public TypedActionResult<ItemStack> focusUse(ItemStack gadgetStack, ItemStack fo
3637
//noinspection DataFlowIssue
3738
lightning.refreshPositionAfterTeleport(pos);
3839
lightning.setChanneler(player);
39-
((VivatechLightning) lightning).vivatech$setThunderless();
40+
lightning.setAttached(VivatechAttachments.THUNDERLESS_LIGHTNING, true);
4041
world.spawnEntity(lightning);
4142
focusStack.damage(1, user, EquipmentSlot.MAINHAND);
4243
return TypedActionResult.success(gadgetStack);
@@ -55,8 +56,4 @@ protected Vec3d findGroundPos(ServerWorld world, Vec3d posInAir) {
5556
world.getTopY(Heightmap.Type.MOTION_BLOCKING, (int) posInAir.x, (int) posInAir.z),
5657
posInAir.z);
5758
}
58-
59-
public interface VivatechLightning {
60-
void vivatech$setThunderless();
61-
}
6259
}

0 commit comments

Comments
 (0)