Compare commits
37 Commits
0.0.5+1.16
...
master
Author | SHA1 | Date | |
---|---|---|---|
9dde7b4288 | |||
40de5445d1 | |||
643e287e23 | |||
e5135deef1 | |||
7cb97d4bb6 | |||
a754b43b7c | |||
|
89b42442fd | ||
|
ac1c09cc5f | ||
8e1712e64c | |||
3f59e506a4 | |||
6382869176 | |||
8941461874 | |||
973f92cc35 | |||
e8940acb39 | |||
c095f7da28 | |||
c484e6d78a | |||
fbb1020ce8 | |||
5258a235b5 | |||
f38f6fbced | |||
ce2e2df2d5 | |||
91fab233a4 | |||
4ebb0279fe | |||
5dbfb589ee | |||
9e0edf763a | |||
8241f88fea | |||
4799ad5903 | |||
f4bb60b819 | |||
f6e94963d2 | |||
1c23d15d2e | |||
dea30e1073 | |||
116c03667f | |||
014ed2cded | |||
dfe547c34b | |||
9096dbd53a | |||
72c85fa67b | |||
401970963f | |||
b097bb7cd5 |
74
CHANGELOG.md
@ -1,5 +1,79 @@
|
||||
# Changelog
|
||||
|
||||
**1.0.4**
|
||||
* Fix Crash When Sneak-Using Dye On A Block
|
||||
|
||||
**1.0.3**
|
||||
* Fix Gravity Crash
|
||||
|
||||
**1.0.2**
|
||||
* Attempt To Fix Structure Generation Crash
|
||||
|
||||
**1.0.1**
|
||||
* Add Advancements
|
||||
* Industrial Laser Can Smelt Nether Gold Ore
|
||||
* Rework Network Chip Recipe
|
||||
|
||||
**1.0.8**
|
||||
* Update Textures
|
||||
|
||||
**Beta 0.2.2**
|
||||
* Update To Fabric Structure API
|
||||
|
||||
**Beta 0.2.1**
|
||||
* Fix Solar Panel Crash
|
||||
|
||||
**Beta 0.2.0**
|
||||
* Add New Textures
|
||||
* Add Russian Translations
|
||||
|
||||
**Beta 0.1.9**
|
||||
* Fix Profiling
|
||||
|
||||
**Beta 0.1.8**
|
||||
* Fix Creative Inventory Breaking
|
||||
|
||||
**Beta 0.1.7**
|
||||
* Improve Industrial Laser Fire
|
||||
|
||||
**Beta 0.1.6**
|
||||
* Improve Energy Teleporter Reliability
|
||||
|
||||
**Beta 0.1.5**
|
||||
* Fix Energy Teleporter Y Issues Again
|
||||
|
||||
**Beta 0.1.4**
|
||||
* Fix Bug Where Off Switches Require Power
|
||||
|
||||
**Beta 0.1.3**
|
||||
* Optimizations
|
||||
* Fix Energy Teleporter Y Issues
|
||||
* Make Industrial Laser Set Fire To Entities
|
||||
* Redolence Solar Panels
|
||||
|
||||
**Beta 0.1.2**
|
||||
* Improve Highlight Rendering
|
||||
|
||||
**Beta 0.1.1**
|
||||
* Fix Texture Names
|
||||
|
||||
**Beta 0.1.0**
|
||||
* Fix Interaction Bug With Phase Shifter Block
|
||||
|
||||
**Beta 0.0.9**
|
||||
* Fix Interaction Bug With Phase Shifter Block
|
||||
|
||||
**Beta 0.0.8**
|
||||
* Add Phase Shifter Block
|
||||
* Fix Bugs
|
||||
* Add Circuit Board To REI
|
||||
|
||||
**Beta 0.0.7**
|
||||
* Fix Structure Generation
|
||||
|
||||
**Beta 0.0.6**
|
||||
* Remove ``DamageSourceAccessor``
|
||||
|
||||
**Beta 0.0.5**
|
||||
* Improve Fabric JSON
|
||||
|
||||
|
@ -17,4 +17,5 @@ Using RoughlyEnoughItems with this mod is highly recommended.
|
||||
## Credits
|
||||
- ``@PoeticRainbow#5928`` on Discord For The Logo And Poster
|
||||
- ``@PoeticRainbow#5928`` on Discord For Their Texture Set
|
||||
- ``@azazelthedemonlord#2563`` on Discord For Their Texture Set
|
||||
- ``@azazelthedemonlord#2563`` on Discord For Their Texture Set
|
||||
- ``kazmurenko`` on CurseForge For Translating To Russian
|
@ -45,9 +45,6 @@ dependencies {
|
||||
modImplementation "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}"
|
||||
include "me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}"
|
||||
|
||||
modImplementation "net.earthcomputer:libstructure:${project.libstructure_version}"
|
||||
include "net.earthcomputer:libstructure:${project.libstructure_version}"
|
||||
|
||||
compileOnly "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
|
||||
}
|
||||
|
||||
|
27
docs/API.md
Normal file
@ -0,0 +1,27 @@
|
||||
# API
|
||||
The public API is in the package ``com.thebrokenrail.energonrelics.api``. Any registries are located in the package ``com.thebrokenrail.energonrelics.registry``. Anything else should be treated as unstable and may change at any moment.
|
||||
|
||||
## Setup
|
||||
|
||||
### ``build.gradle``
|
||||
```gradle
|
||||
repositories {
|
||||
maven { url 'https://maven.thebrokenrail.com' }
|
||||
}
|
||||
dependencies {
|
||||
modImplementation 'com.thebrokenrail:energonrelics:VERSION'
|
||||
// VERSION = "<Mod Version>+<MC Version>", for example "1.0.0+1.16.2"
|
||||
}
|
||||
```
|
||||
|
||||
### ``fabric.mod.json``
|
||||
```json
|
||||
{
|
||||
"depends": {
|
||||
"energonrelics": "1.0.x"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## JavaDoc
|
||||
[View JavaDoc](https://jenkins.thebrokenrail.com/job/EnergonRelics/job/master/JavaDoc/)
|
@ -92,4 +92,14 @@
|
||||
|
||||
## Infuser
|
||||
- Uses Energy To Attempt To Convert An Item To A Different Item
|
||||
- Each Item Has Multiple Outcomes And May Require Different Amount Of Energy
|
||||
- Each Item Has Multiple Outcomes And May Require Different Amount Of Energy
|
||||
|
||||
## Phase Shifter
|
||||
- Two Modes: Input And Output
|
||||
- Mode Is Toggled By Redstone Input
|
||||
- Can Be Dyed
|
||||
- Input Blocks Phase Items
|
||||
- The More Phased Items, The More Power An Input Requires
|
||||
- The Longer An Item Is Phased, The Higher Its Range Is
|
||||
- Periodically, Phased Items Are Rolled
|
||||
- When Phased Items Are Rolled, There Is A 10% Chance Of Success, If It Succeeds it Will Transfer The Phased Item To An Output With Range That Is The Same Color
|
@ -6,4 +6,6 @@
|
||||
|
||||
[View Blocks](BLOCKS.md)
|
||||
|
||||
[View Structures](STRUCTURES.md)
|
||||
[View Structures](STRUCTURES.md)
|
||||
|
||||
[View API](API.md)
|
@ -3,22 +3,21 @@ org.gradle.jvmargs = -Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
minecraft_version = 1.16.2-rc1
|
||||
minecraft_version = 1.16.2
|
||||
curseforge_id = 398250
|
||||
simple_minecraft_version = 1.16-Snapshot
|
||||
yarn_build = 4
|
||||
fabric_loader_version = 0.9.0+build.204
|
||||
simple_minecraft_version = 1.16.2
|
||||
yarn_build = 21
|
||||
fabric_loader_version = 0.9.2+build.206
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.0.5
|
||||
mod_version = 1.0.4
|
||||
maven_group = com.thebrokenrail
|
||||
|
||||
# Dependencies
|
||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||
fabric_api_version = 0.17.0+build.393-1.16
|
||||
fabric_api_version = 0.19.0+build.398-1.16
|
||||
modmenu_version = 1.14.6+build.31
|
||||
cloth_config_version = 4.7.0-unstable
|
||||
autoconfig_version = 3.2.0-unstable
|
||||
libstructure_version = 1.4.1
|
||||
roughlyenoughitems_version = 5.2.0
|
||||
roughlyenoughitems_version = 5.2.3
|
||||
jetbrains_annotations_version = 19.0.0
|
||||
|
@ -5,6 +5,7 @@ import com.thebrokenrail.energonrelics.block.CreativeEnergySourceBlock;
|
||||
import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock;
|
||||
import com.thebrokenrail.energonrelics.block.HolographicSkyBlock;
|
||||
import com.thebrokenrail.energonrelics.block.InfuserBlock;
|
||||
import com.thebrokenrail.energonrelics.block.PhaseShifterBlock;
|
||||
import com.thebrokenrail.energonrelics.block.lightning.LightningRodBaseBlock;
|
||||
import com.thebrokenrail.energonrelics.block.forcefield.ForcefieldProjectorBlock;
|
||||
import com.thebrokenrail.energonrelics.block.forcefield.laser.IndustrialLaserProjectorBlock;
|
||||
@ -32,6 +33,7 @@ import com.thebrokenrail.energonrelics.block.EnergonLightBlock;
|
||||
import com.thebrokenrail.energonrelics.block.SolarPanelBlock;
|
||||
import com.thebrokenrail.energonrelics.block.SwitchBlock;
|
||||
import com.thebrokenrail.energonrelics.api.block.SimpleBlock;
|
||||
import com.thebrokenrail.energonrelics.feature.CustomFeatures;
|
||||
import com.thebrokenrail.energonrelics.item.MultimeterItem;
|
||||
import com.thebrokenrail.energonrelics.item.NetworkChipItem;
|
||||
import com.thebrokenrail.energonrelics.potion.CustomPotions;
|
||||
@ -50,151 +52,162 @@ import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Rarity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||
|
||||
public final class EnergonRelics implements ModInitializer {
|
||||
public static final String NAMESPACE = "energonrelics";
|
||||
|
||||
public static NetworkChipItem NETWORK_CHIP_ITEM;
|
||||
public static final class Items {
|
||||
static {
|
||||
if (ItemGroup.BUILDING_BLOCKS == null) {
|
||||
throw new RuntimeException("Items Loaded Too Early");
|
||||
}
|
||||
}
|
||||
|
||||
public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(new Identifier(NAMESPACE, "item_group"), () -> new ItemStack(NETWORK_CHIP_ITEM));
|
||||
public static final NetworkChipItem NETWORK_CHIP_ITEM;
|
||||
|
||||
public static final EnergonLightBlock ENERGON_LIGHT_BLOCK = new EnergonLightBlock();
|
||||
public static final SolarPanelBlock SOLAR_PANEL_BLOCK = new SolarPanelBlock();
|
||||
public static final SwitchBlock SWITCH_BLOCk = new SwitchBlock();
|
||||
public static final MultimeterItem MULTIMETER_ITEM = new MultimeterItem();
|
||||
public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(new Identifier(NAMESPACE, "item_group"), () -> new ItemStack(Items.NETWORK_CHIP_ITEM));
|
||||
|
||||
public static final ThermalCasingBlock THERMAL_CASING_BLOCK = new ThermalCasingBlock();
|
||||
public static final ThermalGlassBlock THERMAL_GLASS_BLOCK = new ThermalGlassBlock();
|
||||
static {
|
||||
NETWORK_CHIP_ITEM = new NetworkChipItem();
|
||||
}
|
||||
|
||||
public static final BatteryCoreBlock BATTERY_CORE_BLOCk = new BatteryCoreBlock();
|
||||
public static final PassiveBatteryControllerBlock PASSIVE_BATTERY_CONTROLLER_BLOCk = new PassiveBatteryControllerBlock();
|
||||
public static final ActiveBatteryControllerBlock ACTIVE_BATTERY_CONTROLLER_BLOCK = new ActiveBatteryControllerBlock();
|
||||
public static final MultimeterItem MULTIMETER = new MultimeterItem();
|
||||
public static final Item VERIDIUM_ORB = new Item(new Item.Settings().group(ITEM_GROUP).rarity(Rarity.UNCOMMON));
|
||||
public static final Item VERIDIUM_POWDER = new Item(new Item.Settings().group(ITEM_GROUP));
|
||||
public static final Item DEFENSIVE_LASER_CORE = new Item(new Item.Settings().group(ITEM_GROUP));
|
||||
public static final Item CIRCUIT_BOARD = new Item(new Item.Settings().group(ITEM_GROUP));
|
||||
public static final Item VERIDIUM_INGOT = new Item(new Item.Settings().group(ITEM_GROUP));
|
||||
}
|
||||
|
||||
public static final ReactorCoreBlock REACTOR_CORE_BLOCK = new ReactorCoreBlock();
|
||||
public static final ReactorInputBlock REACTOR_INPUT_BLOCK = new ReactorInputBlock();
|
||||
public static final ReactorControllerBlock REACTOR_CONTROLLER_BLOCK = new ReactorControllerBlock();
|
||||
public static final class Blocks {
|
||||
public static final EnergonLightBlock ENERGON_LIGHT = new EnergonLightBlock();
|
||||
public static final SolarPanelBlock SOLAR_PANEL = new SolarPanelBlock();
|
||||
public static final SwitchBlock SWITCH = new SwitchBlock();
|
||||
|
||||
public static final Item VERIDIUM_INGOT_ITEM = new Item(new Item.Settings().group(ITEM_GROUP));
|
||||
public static final SimpleBlock VERIDIUM_ORE_BLOCK = new SimpleBlock(FabricBlockSettings.of(Material.STONE).requiresTool().strength(3f, 3f));
|
||||
public static final SimpleBlock VERIDIUM_BLOCK_BLOCK = new VeridiumBlockBlock();
|
||||
public static final ConfiguredFeature<?, ?> VERIDIUM_ORE_FEATURE = Feature.ORE.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, EnergonRelics.VERIDIUM_ORE_BLOCK.getDefaultState(), 9)).method_30377(32).spreadHorizontally().repeat(2);
|
||||
public static final ThermalCasingBlock THERMAL_CASING = new ThermalCasingBlock();
|
||||
public static final ThermalGlassBlock THERMAL_GLASS = new ThermalGlassBlock();
|
||||
|
||||
public static final Item CIRCUIT_BOARD_ITEM = new Item(new Item.Settings().group(ITEM_GROUP));
|
||||
public static final BatteryCoreBlock BATTERY_CORE = new BatteryCoreBlock();
|
||||
public static final PassiveBatteryControllerBlock PASSIVE_BATTERY_CONTROLLER = new PassiveBatteryControllerBlock();
|
||||
public static final ActiveBatteryControllerBlock ACTIVE_BATTERY_CONTROLLER = new ActiveBatteryControllerBlock();
|
||||
|
||||
public static final Item DEFENSIVE_LASER_CORE_ITEM = new Item(new Item.Settings().group(ITEM_GROUP));
|
||||
public static final DefensiveLaserBlock DEFENSIVE_LASER_BLOCK = new DefensiveLaserBlock();
|
||||
public static final ReactorCoreBlock REACTOR_CORE = new ReactorCoreBlock();
|
||||
public static final ReactorInputBlock REACTOR_INPUT = new ReactorInputBlock();
|
||||
public static final ReactorControllerBlock REACTOR_CONTROLLER = new ReactorControllerBlock();
|
||||
|
||||
public static final BlockBreakerBlock BLOCK_BREAKER_BLOCK = new BlockBreakerBlock();
|
||||
public static final SimpleBlock VERIDIUM_ORE = new SimpleBlock(FabricBlockSettings.of(Material.STONE).requiresTool().strength(3f, 3f));
|
||||
public static final SimpleBlock VERIDIUM_BLOCK = new VeridiumBlockBlock();
|
||||
|
||||
public static final Item VERIDIUM_POWDER_ITEM = new Item(new Item.Settings().group(ITEM_GROUP));
|
||||
public static final DefensiveLaserBlock DEFENSIVE_LASER = new DefensiveLaserBlock();
|
||||
public static final BlockBreakerBlock BLOCK_BREAKER = new BlockBreakerBlock();
|
||||
|
||||
public static final LightningRodBaseBlock LIGHTNING_ROD_BASE_BLOCK = new LightningRodBaseBlock();
|
||||
public static final LightningRodBlock LIGHTNING_ROD_BLOCK = new LightningRodBlock();
|
||||
public static final LightningRodBaseBlock LIGHTNING_ROD_BASE = new LightningRodBaseBlock();
|
||||
public static final LightningRodBlock LIGHTNING_ROD = new LightningRodBlock();
|
||||
|
||||
public static final SpecialRecipeSerializer<DuplicateNetworkChipRecipe> DUPLICATE_NETWORK_CHIP_RECIPE = new SpecialRecipeSerializer<>(DuplicateNetworkChipRecipe::new);
|
||||
public static final ForcefieldBlock FORCEFIELD = new ForcefieldBlock();
|
||||
public static final ForcefieldProjectorBlock FORCEFIELD_PROJECTOR = new ForcefieldProjectorBlock();
|
||||
|
||||
public static final Material FIELD_MATERIAL = new Material.Builder(MaterialColor.CLEAR).replaceable().build();
|
||||
public static final TractorBeamBlock TRACTOR_BEAM = new TractorBeamBlock();
|
||||
public static final RepulsorBeamBlock REPULSOR_BEAM = new RepulsorBeamBlock();
|
||||
public static final TractorBeamProjectorBlock TRACTOR_BEAM_PROJECTOR = new TractorBeamProjectorBlock();
|
||||
|
||||
public static final ForcefieldBlock FORCEFIELD_BLOCK = new ForcefieldBlock();
|
||||
public static final ForcefieldProjectorBlock FORCEFIELD_PROJECTOR_BLOCK = new ForcefieldProjectorBlock();
|
||||
public static final IndustrialLaserBlock INDUSTRIAL_LASER = new IndustrialLaserBlock();
|
||||
public static final IndustrialLaserProjectorBlock INDUSTRIAL_LASER_PROJECTOR = new IndustrialLaserProjectorBlock();
|
||||
|
||||
public static final TractorBeamBlock TRACTOR_BEAM_BLOCK = new TractorBeamBlock();
|
||||
public static final RepulsorBeamBlock REPULSOR_BEAM_BLOCK = new RepulsorBeamBlock();
|
||||
public static final TractorBeamProjectorBlock TRACTOR_BEAM_PROJECTOR_BLOCK = new TractorBeamProjectorBlock();
|
||||
public static final CreativeEnergySourceBlock CREATIVE_ENERGY_SOURCE = new CreativeEnergySourceBlock();
|
||||
public static final HolographicSkyBlock HOLOGRAPHIC_SKY = new HolographicSkyBlock();
|
||||
public static final InfuserBlock INFUSER = new InfuserBlock();
|
||||
|
||||
public static final IndustrialLaserBlock INDUSTRIAL_LASER_BLOCK = new IndustrialLaserBlock();
|
||||
public static final IndustrialLaserProjectorBlock INDUSTRIAL_LASER_PROJECTOR_BLOCK = new IndustrialLaserProjectorBlock();
|
||||
public static final EnergizedObsidianBlock ENERGIZED_OBSIDIAN = new EnergizedObsidianBlock();
|
||||
public static final EnergyBeamBlock ENERGY_BEAM = new EnergyBeamBlock();
|
||||
public static final EnergyPortalBlock ENERGY_PORTAL = new EnergyPortalBlock();
|
||||
public static final EnergyProjectorBlock ENERGY_PROJECTOR = new EnergyProjectorBlock();
|
||||
|
||||
private static final Identifier BEEP_SOUND_ID = new Identifier(NAMESPACE, "beep");
|
||||
private static final SoundEvent BEEP_SOUND_EVENT = new SoundEvent(BEEP_SOUND_ID);
|
||||
public static final PhaseShifterBlock PHASE_SHIFTER = new PhaseShifterBlock();
|
||||
}
|
||||
|
||||
public static final CreativeEnergySourceBlock CREATIVE_ENERGY_SOURCE_BLOCK = new CreativeEnergySourceBlock();
|
||||
public static final class Extras {
|
||||
public static final SpecialRecipeSerializer<DuplicateNetworkChipRecipe> DUPLICATE_NETWORK_CHIP_RECIPE = new SpecialRecipeSerializer<>(DuplicateNetworkChipRecipe::new);
|
||||
|
||||
public static final HolographicSkyBlock HOLOGRAPHIC_SKY_BLOCK = new HolographicSkyBlock();
|
||||
public static final Material FIELD_MATERIAL = new Material.Builder(MaterialColor.CLEAR).replaceable().build();
|
||||
|
||||
public static final InfuserBlock INFUSER_BLOCK = new InfuserBlock();
|
||||
private static final Identifier BEEP_SOUND_ID = new Identifier(NAMESPACE, "beep");
|
||||
private static final SoundEvent BEEP_SOUND_EVENT = new SoundEvent(BEEP_SOUND_ID);
|
||||
|
||||
public static final EnergizedObsidianBlock ENERGIZED_OBSIDIAN_BLOCK = new EnergizedObsidianBlock();
|
||||
public static final EnergyBeamBlock ENERGY_BEAM_BLOCK = new EnergyBeamBlock();
|
||||
public static final EnergyPortalBlock ENERGY_PORTAL_BLOCK = new EnergyPortalBlock();
|
||||
public static final EnergyProjectorBlock ENERGY_PROJECTOR_BLOCK = new EnergyProjectorBlock();
|
||||
public static final Item VERIDIUM_ORB_ITEM = new Item(new Item.Settings().group(ITEM_GROUP).rarity(Rarity.UNCOMMON));
|
||||
public static void playBeep(World world, BlockPos pos) {
|
||||
if (!world.isClient()) {
|
||||
world.playSound(null, pos, BEEP_SOUND_EVENT, SoundCategory.BLOCKS, 0.3f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_ingot"), VERIDIUM_INGOT_ITEM);
|
||||
VERIDIUM_ORE_BLOCK.register("veridium_ore");
|
||||
VERIDIUM_BLOCK_BLOCK.register("veridium_block");
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(NAMESPACE, "veridium_ore"), VERIDIUM_ORE_FEATURE);
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_powder"), VERIDIUM_POWDER_ITEM);
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_orb"), VERIDIUM_ORB_ITEM);
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_ingot"), Items.VERIDIUM_INGOT);
|
||||
Blocks.VERIDIUM_ORE.register("veridium_ore");
|
||||
Blocks.VERIDIUM_BLOCK.register("veridium_block");
|
||||
CustomFeatures.register();
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_powder"), Items.VERIDIUM_POWDER);
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_orb"), Items.VERIDIUM_ORB);
|
||||
|
||||
NETWORK_CHIP_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "network_chip"), new NetworkChipItem());
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "multimeter"), MULTIMETER_ITEM);
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "circuit_board"), CIRCUIT_BOARD_ITEM);
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "network_chip"), Items.NETWORK_CHIP_ITEM);
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "multimeter"), Items.MULTIMETER);
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "circuit_board"), Items.CIRCUIT_BOARD);
|
||||
|
||||
ENERGON_LIGHT_BLOCK.register("energon_light");
|
||||
SOLAR_PANEL_BLOCK.register("solar_panel");
|
||||
SWITCH_BLOCk.register("switch");
|
||||
Blocks.ENERGON_LIGHT.register("energon_light");
|
||||
Blocks.SOLAR_PANEL.register("solar_panel");
|
||||
Blocks.SWITCH.register("switch");
|
||||
|
||||
THERMAL_CASING_BLOCK.register("thermal_casing");
|
||||
THERMAL_GLASS_BLOCK.register("thermal_glass");
|
||||
Blocks.THERMAL_CASING.register("thermal_casing");
|
||||
Blocks.THERMAL_GLASS.register("thermal_glass");
|
||||
|
||||
BATTERY_CORE_BLOCk.register("battery_core");
|
||||
PASSIVE_BATTERY_CONTROLLER_BLOCk.register("passive_battery_controller");
|
||||
ACTIVE_BATTERY_CONTROLLER_BLOCK.register("active_battery_controller");
|
||||
Blocks.BATTERY_CORE.register("battery_core");
|
||||
Blocks.PASSIVE_BATTERY_CONTROLLER.register("passive_battery_controller");
|
||||
Blocks.ACTIVE_BATTERY_CONTROLLER.register("active_battery_controller");
|
||||
|
||||
REACTOR_CORE_BLOCK.register("reactor_core");
|
||||
REACTOR_INPUT_BLOCK.register("reactor_input");
|
||||
REACTOR_CONTROLLER_BLOCK.register("reactor_controller");
|
||||
Blocks.REACTOR_CORE.register("reactor_core");
|
||||
Blocks.REACTOR_INPUT.register("reactor_input");
|
||||
Blocks.REACTOR_CONTROLLER.register("reactor_controller");
|
||||
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "defensive_laser_core"), DEFENSIVE_LASER_CORE_ITEM);
|
||||
DEFENSIVE_LASER_BLOCK.register("defensive_laser");
|
||||
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "defensive_laser_core"), Items.DEFENSIVE_LASER_CORE);
|
||||
Blocks.DEFENSIVE_LASER.register("defensive_laser");
|
||||
|
||||
StructureGeneratorBlock.register();
|
||||
StructureGeneratorBlock.registerBlocks();
|
||||
|
||||
BLOCK_BREAKER_BLOCK.register("block_breaker");
|
||||
Blocks.BLOCK_BREAKER.register("block_breaker");
|
||||
|
||||
CustomPotions.register();
|
||||
|
||||
LIGHTNING_ROD_BASE_BLOCK.register("lightning_rod_base");
|
||||
LIGHTNING_ROD_BLOCK.register("lightning_rod");
|
||||
Blocks.LIGHTNING_ROD_BASE.register("lightning_rod_base");
|
||||
Blocks.LIGHTNING_ROD.register("lightning_rod");
|
||||
|
||||
Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(NAMESPACE, "duplicate_network_chip"), DUPLICATE_NETWORK_CHIP_RECIPE);
|
||||
Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(NAMESPACE, "duplicate_network_chip"), Extras.DUPLICATE_NETWORK_CHIP_RECIPE);
|
||||
|
||||
FORCEFIELD_BLOCK.register("forcefield");
|
||||
FORCEFIELD_PROJECTOR_BLOCK.register("forcefield_projector");
|
||||
Blocks.FORCEFIELD.register("forcefield");
|
||||
Blocks.FORCEFIELD_PROJECTOR.register("forcefield_projector");
|
||||
|
||||
TRACTOR_BEAM_BLOCK.register("tractor_beam");
|
||||
REPULSOR_BEAM_BLOCK.register("repulsor_beam");
|
||||
TRACTOR_BEAM_PROJECTOR_BLOCK.register("tractor_beam_projector");
|
||||
Blocks.TRACTOR_BEAM.register("tractor_beam");
|
||||
Blocks.REPULSOR_BEAM.register("repulsor_beam");
|
||||
Blocks.TRACTOR_BEAM_PROJECTOR.register("tractor_beam_projector");
|
||||
|
||||
INDUSTRIAL_LASER_BLOCK.register("industrial_laser");
|
||||
INDUSTRIAL_LASER_PROJECTOR_BLOCK.register("industrial_laser_projector");
|
||||
Blocks.INDUSTRIAL_LASER.register("industrial_laser");
|
||||
Blocks.INDUSTRIAL_LASER_PROJECTOR.register("industrial_laser_projector");
|
||||
|
||||
Registry.register(Registry.SOUND_EVENT, BEEP_SOUND_ID, BEEP_SOUND_EVENT);
|
||||
Registry.register(Registry.SOUND_EVENT, Extras.BEEP_SOUND_ID, Extras.BEEP_SOUND_EVENT);
|
||||
|
||||
CREATIVE_ENERGY_SOURCE_BLOCK.register("creative_energy_source");
|
||||
Blocks.CREATIVE_ENERGY_SOURCE.register("creative_energy_source");
|
||||
|
||||
HOLOGRAPHIC_SKY_BLOCK.register("holographic_sky");
|
||||
Blocks.HOLOGRAPHIC_SKY.register("holographic_sky");
|
||||
|
||||
INFUSER_BLOCK.register("infuser");
|
||||
Blocks.INFUSER.register("infuser");
|
||||
|
||||
ENERGIZED_OBSIDIAN_BLOCK.register("energized_obsidian");
|
||||
ENERGY_BEAM_BLOCK.register("energy_beam");
|
||||
ENERGY_PORTAL_BLOCK.register("energy_portal");
|
||||
ENERGY_PROJECTOR_BLOCK.register("energy_projector");
|
||||
}
|
||||
Blocks.ENERGIZED_OBSIDIAN.register("energized_obsidian");
|
||||
Blocks.ENERGY_BEAM.register("energy_beam");
|
||||
Blocks.ENERGY_PORTAL.register("energy_portal");
|
||||
Blocks.ENERGY_PROJECTOR.register("energy_projector");
|
||||
|
||||
public static void playBeep(World world, BlockPos pos) {
|
||||
if (!world.isClient()) {
|
||||
world.playSound(null, pos, BEEP_SOUND_EVENT, SoundCategory.BLOCKS, 0.3f, 1f);
|
||||
}
|
||||
Blocks.PHASE_SHIFTER.register("phase_shifter");
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class SimpleBlock extends Block {
|
||||
@SuppressWarnings("SameReturnValue")
|
||||
@ApiStatus.OverrideOnly
|
||||
protected ItemGroup getItemGroup() {
|
||||
return EnergonRelics.ITEM_GROUP;
|
||||
return EnergonRelics.Items.ITEM_GROUP;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,17 +1,25 @@
|
||||
package com.thebrokenrail.energonrelics.api.block;
|
||||
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Simple Block With Entity
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class SimpleBlockWithEntity extends SimpleBlock implements BlockEntityProvider {
|
||||
protected BlockEntityType<BlockEntity> type;
|
||||
|
||||
@ -35,4 +43,35 @@ public abstract class SimpleBlockWithEntity extends SimpleBlock implements Block
|
||||
public BlockEntity createBlockEntity(BlockView world) {
|
||||
return getFactory().apply(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does This Block's Block Entity Have An Inventory
|
||||
* @return Has Inventory
|
||||
*/
|
||||
@ApiStatus.OverrideOnly
|
||||
protected boolean hasInventory() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
|
||||
if (state.getBlock() != newState.getBlock() && hasInventory()) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof Inventory) {
|
||||
ItemScatterer.spawn(world, pos, (Inventory) blockEntity);
|
||||
world.updateComparators(pos, this);
|
||||
}
|
||||
}
|
||||
super.onStateReplaced(state, world, pos, newState, moved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorOutput(BlockState state) {
|
||||
return hasInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
return hasInventory() ? ScreenHandler.calculateComparatorOutput(world.getBlockEntity(pos)) : 0;
|
||||
}
|
||||
}
|
||||
|
@ -60,13 +60,13 @@ public abstract class EnergyBlock extends SimpleBlockWithEntity {
|
||||
BlockEntity entity = world.getBlockEntity(pos);
|
||||
if (entity instanceof EnergyProviderBlockEntity && ((EnergyProviderBlockEntity) entity).isEnergyProvider()) {
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) {
|
||||
if (stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM) {
|
||||
if (!((EnergyProviderBlockEntity) entity).hasStack()) {
|
||||
if (!world.isClient()) {
|
||||
((EnergyProviderBlockEntity) entity).placeStack(stack, world);
|
||||
stack.setCount(0);
|
||||
}
|
||||
EnergonRelics.playBeep(world, pos);
|
||||
EnergonRelics.Extras.playBeep(world, pos);
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
return ActionResult.FAIL;
|
||||
@ -77,7 +77,7 @@ public abstract class EnergyBlock extends SimpleBlockWithEntity {
|
||||
ItemStack newStack = ((EnergyProviderBlockEntity) entity).takeStack(world);
|
||||
player.setStackInHand(hand, newStack);
|
||||
}
|
||||
EnergonRelics.playBeep(world, pos);
|
||||
EnergonRelics.Extras.playBeep(world, pos);
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
return ActionResult.FAIL;
|
||||
|
@ -54,7 +54,7 @@ public class EnergyProviderBlockEntity extends BlockEntity implements BlockEntit
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public final boolean isNetwork(int network) {
|
||||
return isEnergyProvider() && EnergonRelics.NETWORK_CHIP_ITEM.getID(stack) == network;
|
||||
return isEnergyProvider() && EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack) == network;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,9 +123,9 @@ public class EnergyProviderBlockEntity extends BlockEntity implements BlockEntit
|
||||
|
||||
@Override
|
||||
public List<EnergyTickable> startTick() {
|
||||
if (isEnergyProvider() && stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) {
|
||||
if (isEnergyProvider() && stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM) {
|
||||
NetworkComponent component = NetworkComponent.getInstance((ServerWorld) Objects.requireNonNull(getWorld()));
|
||||
List<BlockPosWithDimension> sources = component.getSourcesPos(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack));
|
||||
List<BlockPosWithDimension> sources = component.getSourcesPos(EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack));
|
||||
if (!sources.contains(new BlockPosWithDimension(getPos(), getWorld().getRegistryKey()))) {
|
||||
takeStack(getWorld());
|
||||
}
|
||||
@ -145,9 +145,9 @@ public class EnergyProviderBlockEntity extends BlockEntity implements BlockEntit
|
||||
NetworkComponent component = NetworkComponent.getInstance(serverWorld);
|
||||
BlockPosWithDimension newPos = new BlockPosWithDimension(pos, world.getRegistryKey());
|
||||
if (remove) {
|
||||
component.removeSource(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack), newPos);
|
||||
component.removeSource(EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack), newPos);
|
||||
} else {
|
||||
component.addSource(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack), newPos);
|
||||
component.addSource(EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack), newPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,11 @@ public abstract class EnergyReceiverBlockEntity extends EnergyProviderBlockEntit
|
||||
if (providers.size() > 0) {
|
||||
action.expandPayments(providers.size());
|
||||
for (EnergyProviderBlockEntity provider : providers) {
|
||||
provider.addPropagatedAction(action);
|
||||
if (action.amountOwed() > 0) {
|
||||
provider.addPropagatedAction(action);
|
||||
} else {
|
||||
action.pay(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
action.pay(0);
|
||||
|
@ -14,13 +14,17 @@ public interface EnergyTickable {
|
||||
*/
|
||||
@ApiStatus.OverrideOnly
|
||||
List<EnergyTickable> startTick();
|
||||
|
||||
/**
|
||||
* Logic Tick
|
||||
*/
|
||||
@ApiStatus.OverrideOnly
|
||||
void logicTick();
|
||||
|
||||
/**
|
||||
* Get ID
|
||||
*
|
||||
* Used By The Debug Profiler
|
||||
* @return ID
|
||||
*/
|
||||
@ApiStatus.OverrideOnly
|
||||
|
@ -14,14 +14,25 @@ import java.util.Objects;
|
||||
/**
|
||||
* Energy Ticker
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public class EnergyTicker {
|
||||
public final class EnergyTicker {
|
||||
private static final List<EnergyTickable> scheduled = new ArrayList<>();
|
||||
private static List<EnergyTickable> allLoaded = Collections.emptyList();
|
||||
|
||||
/**
|
||||
* Get All Loaded Energy Tickers
|
||||
*
|
||||
* Only Usable In {@link EnergyTickable#logicTick()}
|
||||
* @return List Of All Loaded Energy Tickers
|
||||
*/
|
||||
public static List<EnergyTickable> getAllLoaded() {
|
||||
return allLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule For Next Energy Tick
|
||||
* @param tickable Object To Tick
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static void schedule(EnergyTickable tickable) {
|
||||
scheduled.add(tickable);
|
||||
}
|
||||
@ -30,12 +41,15 @@ public class EnergyTicker {
|
||||
* Tick Energy
|
||||
* @param world World
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static void tick(World world) {
|
||||
if (Objects.requireNonNull(world.getServer()).getThread() == Thread.currentThread()) {
|
||||
world.getProfiler().push(EnergonRelics.NAMESPACE);
|
||||
|
||||
NetworkComponent.getInstance((ServerWorld) world).clearCache();
|
||||
|
||||
world.getProfiler().push("startTick");
|
||||
|
||||
List<EnergyTickable> started = new ArrayList<>();
|
||||
|
||||
List<EnergyTickable> temp = new ArrayList<>(scheduled);
|
||||
@ -43,7 +57,7 @@ public class EnergyTicker {
|
||||
while (!temp.isEmpty()) {
|
||||
for (EnergyTickable tickable : temp) {
|
||||
if (!started.contains(tickable)) {
|
||||
world.getProfiler().push(() -> tickable.getID() + " startTick");
|
||||
world.getProfiler().push(tickable::getID);
|
||||
|
||||
temp2.addAll(tickable.startTick());
|
||||
started.add(tickable);
|
||||
@ -51,14 +65,25 @@ public class EnergyTicker {
|
||||
world.getProfiler().pop();
|
||||
}
|
||||
}
|
||||
temp.clear();
|
||||
temp.addAll(temp2);
|
||||
|
||||
List<EnergyTickable> temp3 = temp;
|
||||
temp = temp2;
|
||||
temp2 = temp3;
|
||||
temp2.clear();
|
||||
}
|
||||
|
||||
allLoaded = Collections.unmodifiableList(started);
|
||||
|
||||
world.getProfiler().push("shuffle");
|
||||
Collections.shuffle(started, world.random);
|
||||
world.getProfiler().pop();
|
||||
|
||||
world.getProfiler().pop();
|
||||
|
||||
world.getProfiler().push("logicTick");
|
||||
|
||||
for (EnergyTickable tickable : started) {
|
||||
world.getProfiler().push(() -> tickable.getID() + " logicTick");
|
||||
world.getProfiler().push(tickable::getID);
|
||||
|
||||
tickable.logicTick();
|
||||
|
||||
@ -66,7 +91,11 @@ public class EnergyTicker {
|
||||
}
|
||||
|
||||
world.getProfiler().pop();
|
||||
|
||||
world.getProfiler().pop();
|
||||
}
|
||||
scheduled.clear();
|
||||
|
||||
allLoaded = Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.thebrokenrail.energonrelics.api.item;
|
||||
|
||||
import net.minecraft.text.MutableText;
|
||||
|
||||
/**
|
||||
* Implement To Provide Extra Information In Multimeter Output
|
||||
*/
|
||||
public interface MultimeterExtra {
|
||||
/**
|
||||
* Get Extra Information
|
||||
* @return Text
|
||||
*/
|
||||
MutableText getExtra();
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package com.thebrokenrail.energonrelics.block;
|
||||
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.api.block.energy.EnergyBlock;
|
||||
import com.thebrokenrail.energonrelics.block.entity.shifter.PhaseShifterBlockEntity;
|
||||
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.DyeItem;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.HopperScreenHandler;
|
||||
import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PhaseShifterBlock extends EnergyBlock {
|
||||
public static final BooleanProperty POWERED = Properties.POWERED;
|
||||
public static final BooleanProperty IS_OUTPUT = BooleanProperty.of("is_output");
|
||||
public static final EnumProperty<DyeColor> COLOR = EnumProperty.of("color", DyeColor.class);
|
||||
|
||||
public PhaseShifterBlock() {
|
||||
super(FabricBlockSettings.copy(Blocks.IRON_BLOCK).lightLevel(state -> state.get(POWERED) ? 13 : 0).emissiveLighting((state, world, pos) -> state.get(POWERED)));
|
||||
setDefaultState(getDefaultState().with(POWERED, false).with(IS_OUTPUT, false).with(COLOR, DyeColor.WHITE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(POWERED, IS_OUTPUT, COLOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
|
||||
return PhaseShifterBlockEntity::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return getDefaultState().with(IS_OUTPUT, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
|
||||
if (!world.isClient()) {
|
||||
boolean bl = state.get(IS_OUTPUT);
|
||||
if (bl != world.isReceivingRedstonePower(pos)) {
|
||||
if (bl) {
|
||||
world.getBlockTickScheduler().schedule(pos, this, 4);
|
||||
} else {
|
||||
world.setBlockState(pos, state.cycle(IS_OUTPUT), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||
if (state.get(IS_OUTPUT) && !world.isReceivingRedstonePower(pos)) {
|
||||
world.setBlockState(pos, state.cycle(IS_OUTPUT), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
ActionResult result = super.onUse(state, world, pos, player, hand, hit);
|
||||
if (result != ActionResult.PASS) {
|
||||
return result;
|
||||
} else {
|
||||
BlockEntity entity = world.getBlockEntity(pos);
|
||||
if (entity instanceof Inventory) {
|
||||
if (!world.isClient()) {
|
||||
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, inv, player2) -> new HopperScreenHandler(i, inv, (Inventory) entity), new TranslatableText("block." + EnergonRelics.NAMESPACE + ".phase_shifter")));
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(Identifier id) {
|
||||
super.register(id);
|
||||
UseBlockCallback.EVENT.register((player, world, hand, hit) -> {
|
||||
if (!player.isSpectator() && player.shouldCancelInteraction()) {
|
||||
BlockState state = world.getBlockState(hit.getBlockPos());
|
||||
if (state.getBlock() == PhaseShifterBlock.this) {
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
if (stack.getItem() instanceof DyeItem) {
|
||||
DyeColor newColor = ((DyeItem) stack.getItem()).getColor();
|
||||
if (state.get(PhaseShifterBlock.COLOR) != newColor) {
|
||||
world.setBlockState(hit.getBlockPos(), state.with(PhaseShifterBlock.COLOR, newColor));
|
||||
if (!player.isCreative()) {
|
||||
stack.decrement(1);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasInventory() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -22,26 +22,27 @@ import java.util.function.Function;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class SwitchBlock extends EnergyBlock {
|
||||
public static final BooleanProperty POWERED = Properties.POWERED;
|
||||
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
|
||||
|
||||
public SwitchBlock() {
|
||||
super(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1.5f, 6.0f));
|
||||
setDefaultState(getDefaultState().with(POWERED, false));
|
||||
setDefaultState(getDefaultState().with(POWERED, false).with(ACTIVE, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return getDefaultState().with(POWERED, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
|
||||
return getDefaultState().with(ACTIVE, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
|
||||
if (!world.isClient()) {
|
||||
boolean bl = state.get(POWERED);
|
||||
boolean bl = state.get(ACTIVE);
|
||||
if (bl != world.isReceivingRedstonePower(pos)) {
|
||||
if (bl) {
|
||||
world.getBlockTickScheduler().schedule(pos, this, 4);
|
||||
} else {
|
||||
world.setBlockState(pos, state.cycle(POWERED), 2);
|
||||
world.setBlockState(pos, state.cycle(ACTIVE), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,14 +50,14 @@ public class SwitchBlock extends EnergyBlock {
|
||||
|
||||
@Override
|
||||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||
if (state.get(POWERED) && !world.isReceivingRedstonePower(pos)) {
|
||||
world.setBlockState(pos, state.cycle(POWERED), 2);
|
||||
if (state.get(ACTIVE) && !world.isReceivingRedstonePower(pos)) {
|
||||
world.setBlockState(pos, state.cycle(ACTIVE), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(POWERED);
|
||||
builder.add(POWERED, ACTIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,7 +5,6 @@ import com.thebrokenrail.energonrelics.api.energy.Action;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock;
|
||||
import com.thebrokenrail.energonrelics.mixin.DamageSourceAccessor;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.Entity;
|
||||
@ -49,7 +48,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
|
||||
if (hasWorld()) {
|
||||
return super.getCachedState();
|
||||
} else {
|
||||
return EnergonRelics.DEFENSIVE_LASER_BLOCK.getDefaultState();
|
||||
return EnergonRelics.Blocks.DEFENSIVE_LASER.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,7 +179,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
|
||||
return new ItemEntity(getWorld(), posVec.getX(), posVec.getY(), posVec.getZ());
|
||||
}
|
||||
|
||||
private static final DamageSource DAMAGE_SOURCE = DamageSourceAccessor.createDamageSource(EnergonRelics.NAMESPACE + ".defensive_laser").setScaledWithDifficulty().setExplosive();
|
||||
private static final DamageSource DAMAGE_SOURCE = new DamageSource(EnergonRelics.NAMESPACE + ".defensive_laser").setScaledWithDifficulty().setExplosive();
|
||||
|
||||
private void fire(World world, BlockPos pos) {
|
||||
List<LivingEntity> entities = getEntities(entity -> true);
|
||||
|
@ -5,6 +5,7 @@ import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import com.thebrokenrail.energonrelics.api.energy.tick.EnergyTickable;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
import java.util.List;
|
||||
@ -25,7 +26,7 @@ public class SolarPanelBlockEntity extends EnergyGeneratorBlockEntity {
|
||||
for (Direction side : Direction.values()) {
|
||||
light = Math.max(light, getLight(side));
|
||||
}
|
||||
return light;
|
||||
return (int) (((float) light) * Math.max(0, MathHelper.cos(Objects.requireNonNull(getWorld()).getSkyAngleRadians(1f))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,8 +3,11 @@ package com.thebrokenrail.energonrelics.block.entity;
|
||||
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.api.energy.Action;
|
||||
import com.thebrokenrail.energonrelics.block.SwitchBlock;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
|
||||
public SwitchBlockEntity(BlockEntityType<?> type) {
|
||||
super(type);
|
||||
@ -12,6 +15,11 @@ public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
|
||||
|
||||
@Override
|
||||
protected void energyTick() {
|
||||
if (getCachedState().get(SwitchBlock.ACTIVE)) {
|
||||
addAction(Action.createBlockStatePropertyAction(HardcodedConfig.SWITCH_ENERGY_REQUIRED, SwitchBlock.POWERED, true, false));
|
||||
} else if (getCachedState().get(SwitchBlock.POWERED)) {
|
||||
Objects.requireNonNull(getWorld()).setBlockState(getPos(), getCachedState().with(SwitchBlock.POWERED, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,6 +39,6 @@ public class SwitchBlockEntity extends EnergyReceiverBlockEntity {
|
||||
}
|
||||
|
||||
private boolean isActive() {
|
||||
return getCachedState().get(SwitchBlock.POWERED);
|
||||
return getCachedState().get(SwitchBlock.ACTIVE) && getCachedState().get(SwitchBlock.POWERED);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class PassiveBatteryControllerBlockEntity extends EnergyReceiverBlockEnti
|
||||
}
|
||||
|
||||
public static boolean isInvalidBlock(BlockState block) {
|
||||
return !block.isOf(EnergonRelics.THERMAL_GLASS_BLOCK) && !block.isOf(EnergonRelics.THERMAL_CASING_BLOCK);
|
||||
return !block.isOf(EnergonRelics.Blocks.THERMAL_GLASS) && !block.isOf(EnergonRelics.Blocks.THERMAL_CASING);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,7 @@ import com.thebrokenrail.energonrelics.block.entity.forcefield.FieldProjectorBlo
|
||||
import com.thebrokenrail.energonrelics.block.forcefield.laser.IndustrialLaserProjectorBlock;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import com.thebrokenrail.energonrelics.potion.CustomPotions;
|
||||
import com.thebrokenrail.energonrelics.registry.laser.IndustrialLaserRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@ -20,14 +21,14 @@ import net.minecraft.world.explosion.Explosion;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class IndustrialLaserBlockEntity extends FieldProjectorBlockEntity {
|
||||
public class IndustrialLaserProjectorBlockEntity extends FieldProjectorBlockEntity {
|
||||
private BlockPos targetPos;
|
||||
private BlockState targetState;
|
||||
|
||||
private int progress = 0;
|
||||
|
||||
public IndustrialLaserBlockEntity(BlockEntityType<?> type) {
|
||||
super(type, state -> EnergonRelics.INDUSTRIAL_LASER_BLOCK);
|
||||
public IndustrialLaserProjectorBlockEntity(BlockEntityType<?> type) {
|
||||
super(type, state -> EnergonRelics.Blocks.INDUSTRIAL_LASER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,7 +66,7 @@ public class IndustrialLaserBlockEntity extends FieldProjectorBlockEntity {
|
||||
Block.dropStack(getWorld(), targetPos, IndustrialLaserRegistry.get(targetState.getBlock(), getWorld().random));
|
||||
getWorld().breakBlock(targetPos, false);
|
||||
|
||||
if (targetState.getBlock() == EnergonRelics.VERIDIUM_ORE_BLOCK) {
|
||||
if (targetState.getBlock() == EnergonRelics.Blocks.VERIDIUM_ORE) {
|
||||
AreaEffectCloudEntity areaEffectCloudEntity = new AreaEffectCloudEntity(getWorld(), targetPos.getX() + 0.5d, targetPos.getY() + 0.5d, targetPos.getZ() + 0.5d);
|
||||
areaEffectCloudEntity.setRadius(1.2f);
|
||||
areaEffectCloudEntity.setRadiusOnUse(-0.5f);
|
@ -3,9 +3,9 @@ package com.thebrokenrail.energonrelics.block.entity.infuser;
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.api.energy.Action;
|
||||
import com.thebrokenrail.energonrelics.api.item.MultimeterExtra;
|
||||
import com.thebrokenrail.energonrelics.block.InfuserBlock;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import com.thebrokenrail.energonrelics.item.MultimeterItem;
|
||||
import com.thebrokenrail.energonrelics.registry.infuser.data.InfuserAction;
|
||||
import com.thebrokenrail.energonrelics.registry.infuser.data.InfuserEntry;
|
||||
import com.thebrokenrail.energonrelics.registry.infuser.InfuserRegistry;
|
||||
@ -20,7 +20,7 @@ import net.minecraft.util.Formatting;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class InfuserBlockEntity extends EnergyReceiverBlockEntity implements MultimeterItem.MultimeterExtra {
|
||||
public class InfuserBlockEntity extends EnergyReceiverBlockEntity implements MultimeterExtra {
|
||||
public InfuserBlockEntity(BlockEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class EnergyProjectorBlockEntity extends FieldProjectorBlockEntity {
|
||||
private BlockState targetState;
|
||||
|
||||
public EnergyProjectorBlockEntity(BlockEntityType<?> type) {
|
||||
super(type, state -> EnergonRelics.ENERGY_BEAM_BLOCK);
|
||||
super(type, state -> EnergonRelics.Blocks.ENERGY_BEAM);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,10 +44,10 @@ public class EnergyProjectorBlockEntity extends FieldProjectorBlockEntity {
|
||||
boolean isObsidian;
|
||||
if (targetState.getBlock() == Blocks.OBSIDIAN) {
|
||||
isObsidian = true;
|
||||
targetState = EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK.getDefaultState();
|
||||
targetState = EnergonRelics.Blocks.ENERGIZED_OBSIDIAN.getDefaultState();
|
||||
getWorld().setBlockState(targetPos, targetState);
|
||||
} else {
|
||||
isObsidian = targetState.getBlock() == EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK;
|
||||
isObsidian = targetState.getBlock() == EnergonRelics.Blocks.ENERGIZED_OBSIDIAN;
|
||||
}
|
||||
|
||||
if (isObsidian) {
|
||||
|
@ -17,7 +17,7 @@ public class ReactorInputBlockEntity extends BlockEntity implements Inventory {
|
||||
super(type);
|
||||
}
|
||||
|
||||
private final int INVENTORY_SIZE = 5;
|
||||
public final static int INVENTORY_SIZE = 5;
|
||||
|
||||
private final DefaultedList<ItemStack> inv = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY);
|
||||
|
||||
|
@ -0,0 +1,267 @@
|
||||
package com.thebrokenrail.energonrelics.block.entity.shifter;
|
||||
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.api.energy.Action;
|
||||
import com.thebrokenrail.energonrelics.api.energy.tick.EnergyTickable;
|
||||
import com.thebrokenrail.energonrelics.api.energy.tick.EnergyTicker;
|
||||
import com.thebrokenrail.energonrelics.api.item.MultimeterExtra;
|
||||
import com.thebrokenrail.energonrelics.block.PhaseShifterBlock;
|
||||
import com.thebrokenrail.energonrelics.block.entity.reactor.ReactorInputBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import com.thebrokenrail.energonrelics.util.WeightedList;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Inventories;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PhaseShifterBlockEntity extends EnergyReceiverBlockEntity implements Inventory, MultimeterExtra {
|
||||
private final static int INVENTORY_SIZE = ReactorInputBlockEntity.INVENTORY_SIZE;
|
||||
|
||||
private final DefaultedList<ItemStack> inv = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY);
|
||||
|
||||
private int cooldown = 0;
|
||||
|
||||
public PhaseShifterBlockEntity(BlockEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return inv.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
boolean empty = false;
|
||||
for (ItemStack stack : inv) {
|
||||
if (stack.isEmpty()) {
|
||||
empty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return empty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack(int slot) {
|
||||
return inv.get(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStack(int slot, int amount) {
|
||||
ItemStack stack = Inventories.splitStack(inv, slot, amount);
|
||||
if (!stack.isEmpty()) {
|
||||
markDirty();
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStack(int slot) {
|
||||
return Inventories.removeStack(inv, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(int slot, ItemStack stack) {
|
||||
inv.set(slot, stack);
|
||||
if (stack.getCount() > getMaxCountPerStack()) {
|
||||
stack.setCount(getMaxCountPerStack());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerUse(PlayerEntity player) {
|
||||
if (Objects.requireNonNull(getWorld()).getBlockEntity(getPos()) != this) {
|
||||
return false;
|
||||
} else {
|
||||
return player.squaredDistanceTo((double) getPos().getX() + 0.5D, (double) getPos().getY() + 0.5D, (double) getPos().getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
inv.clear();
|
||||
}
|
||||
|
||||
private final List<PhasedItem> phasedItems = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void fromTag(BlockState state, CompoundTag tag) {
|
||||
super.fromTag(state, tag);
|
||||
inv.clear();
|
||||
Inventories.fromTag(tag, inv);
|
||||
cooldown = tag.getInt("Cooldown");
|
||||
|
||||
phasedItems.clear();
|
||||
Tag list = tag.get("PhasedItems");
|
||||
if (list instanceof ListTag) {
|
||||
ListTag itemsTag = (ListTag) list;
|
||||
for (int i = 0; i < itemsTag.size(); i++) {
|
||||
phasedItems.add(PhasedItem.fromTag(itemsTag.getCompound(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int canInsert(ItemStack stack) {
|
||||
if (stack.getCount() <= getMaxCountPerStack()) {
|
||||
for (int slot = 0; slot < size(); slot++) {
|
||||
ItemStack oldStack = getStack(slot);
|
||||
if (oldStack.isItemEqual(stack)) {
|
||||
int newCount = oldStack.getCount() + stack.getCount();
|
||||
if (newCount <= Math.min(oldStack.getMaxCount(), getMaxCountPerStack())) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int slot = 0; slot < size(); slot++) {
|
||||
ItemStack oldStack = getStack(slot);
|
||||
if (oldStack.isEmpty()) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private long getCost() {
|
||||
return getCachedState().get(PhaseShifterBlock.IS_OUTPUT) ? HardcodedConfig.PHASE_SHIFTER_OUTPUT_ENERGY_REQUIRED : HardcodedConfig.PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_BASE + (HardcodedConfig.PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_PER_ITEM * phasedItems.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void energyTick() {
|
||||
assert getWorld() != null;
|
||||
|
||||
addAction(Action.createBlockStatePropertyAction(getCost(), PhaseShifterBlock.POWERED, true, false));
|
||||
|
||||
boolean dirty = false;
|
||||
|
||||
if (cooldown > 0) {
|
||||
cooldown--;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
if (getCachedState().get(PhaseShifterBlock.POWERED) && !getCachedState().get(PhaseShifterBlock.IS_OUTPUT)) {
|
||||
List<PhaseShifterBlockEntity> outputs = new ArrayList<>();
|
||||
for (EnergyTickable tickable : EnergyTicker.getAllLoaded()) {
|
||||
if (tickable instanceof PhaseShifterBlockEntity && ((PhaseShifterBlockEntity) tickable).getCachedState().get(PhaseShifterBlock.IS_OUTPUT) && Objects.requireNonNull(((PhaseShifterBlockEntity) tickable).getWorld()).getRegistryKey() == getWorld().getRegistryKey() && ((PhaseShifterBlockEntity) tickable).cooldown == 0 && ((PhaseShifterBlockEntity) tickable).getCachedState().get(PhaseShifterBlock.COLOR) == getCachedState().get(PhaseShifterBlock.COLOR)) {
|
||||
outputs.add((PhaseShifterBlockEntity) tickable);
|
||||
}
|
||||
}
|
||||
|
||||
if (phasedItems.size() > 0) {
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
Iterator<PhasedItem> iterator = phasedItems.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
PhasedItem item = iterator.next();
|
||||
|
||||
if (item.cooldown > 0) {
|
||||
item.cooldown--;
|
||||
} else {
|
||||
Map<PhaseShifterBlockEntity, Integer> validOutputs = new HashMap<>();
|
||||
for (PhaseShifterBlockEntity output : outputs) {
|
||||
int slot = output.canInsert(item.item);
|
||||
if (slot != -1 && output.getPos().isWithinDistance(getPos(), item.getRange())) {
|
||||
validOutputs.put(output, slot);
|
||||
}
|
||||
}
|
||||
|
||||
boolean success = validOutputs.size() > 0 && HardcodedConfig.PHASE_SHIFTER_SUCCESS_CHANCE >= getWorld().random.nextFloat();
|
||||
|
||||
if (success) {
|
||||
WeightedList<PhaseShifterBlockEntity> weightedList = new WeightedList<>();
|
||||
for (PhaseShifterBlockEntity output : validOutputs.keySet()) {
|
||||
weightedList.add(1, output);
|
||||
}
|
||||
|
||||
PhaseShifterBlockEntity output = weightedList.pick(getWorld().random);
|
||||
|
||||
int slot = validOutputs.get(output);
|
||||
|
||||
ItemStack stack = item.item.copy();
|
||||
stack.increment(output.getStack(slot).getCount());
|
||||
|
||||
output.setStack(slot, stack);
|
||||
|
||||
output.resetCooldown();
|
||||
|
||||
output.markDirty();
|
||||
|
||||
iterator.remove();
|
||||
} else {
|
||||
item.roll++;
|
||||
item.cooldown = HardcodedConfig.PHASE_SHIFTER_INPUT_ROLL_COOLDOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cooldown == 0) {
|
||||
ItemStack next = ItemStack.EMPTY;
|
||||
|
||||
for (int slot = 0; slot < size(); slot++) {
|
||||
ItemStack stack = getStack(slot);
|
||||
if (!stack.isEmpty()) {
|
||||
next = stack.split(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!next.isEmpty()) {
|
||||
phasedItems.add(new PhasedItem(next));
|
||||
resetCooldown();
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
} else if (phasedItems.size() > 0) {
|
||||
phasedItems.clear();
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
if (dirty) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void resetCooldown() {
|
||||
cooldown = getCachedState().get(PhaseShifterBlock.IS_OUTPUT) ? HardcodedConfig.PHASE_SHIFTER_OUTPUT_COOLDOWN : HardcodedConfig.PHASE_SHIFTER_INPUT_COOLDOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
super.toTag(tag);
|
||||
Inventories.toTag(tag, inv);
|
||||
tag.putInt("Cooldown", cooldown);
|
||||
|
||||
ListTag itemsTag = new ListTag();
|
||||
for (PhasedItem item : phasedItems) {
|
||||
itemsTag.add(item.toTag());
|
||||
}
|
||||
tag.put("PhasedItems", itemsTag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableText getExtra() {
|
||||
return getCachedState().get(PhaseShifterBlock.IS_OUTPUT) ? null : new TranslatableText("text." + EnergonRelics.NAMESPACE + ".phase_shifter_extra", new LiteralText(String.valueOf(phasedItems.size())).formatted(Formatting.WHITE));
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.thebrokenrail.energonrelics.block.entity.shifter;
|
||||
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
class PhasedItem {
|
||||
final ItemStack item;
|
||||
int cooldown = 0;
|
||||
int roll = 0;
|
||||
|
||||
PhasedItem(ItemStack item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
int getRange() {
|
||||
return HardcodedConfig.PHASE_SHIFTER_INPUT_RANGE_BASE + (roll * HardcodedConfig.PHASE_SHIFTER_INPUT_RANGE_INCREMENT);
|
||||
}
|
||||
|
||||
CompoundTag toTag() {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("Item", item.toTag(new CompoundTag()));
|
||||
tag.putInt("Cooldown", cooldown);
|
||||
tag.putInt("Roll", roll);
|
||||
return tag;
|
||||
}
|
||||
|
||||
static PhasedItem fromTag(CompoundTag tag) {
|
||||
PhasedItem item = new PhasedItem(ItemStack.fromTag(tag.getCompound("Item")));
|
||||
item.cooldown = tag.getInt("Cooldown");
|
||||
item.roll = tag.getInt("Roll");
|
||||
return item;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ public class StructureGeneratorBlockEntity extends BlockEntity {
|
||||
StructurePart<?> create(World world, Random random, List<StructurePart.Transformation> transformations);
|
||||
}
|
||||
|
||||
private boolean hasSeed = false;
|
||||
private long seed = 0;
|
||||
private boolean generated = false;
|
||||
|
||||
@ -31,12 +32,14 @@ public class StructureGeneratorBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public void setSeed(long seed) {
|
||||
hasSeed = true;
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag tag) {
|
||||
super.toTag(tag);
|
||||
tag.putBoolean("HasSeed", hasSeed);
|
||||
tag.putLong("Seed", seed);
|
||||
tag.putBoolean("Generated", generated);
|
||||
return tag;
|
||||
@ -45,12 +48,17 @@ public class StructureGeneratorBlockEntity extends BlockEntity {
|
||||
@Override
|
||||
public void fromTag(BlockState state, CompoundTag tag) {
|
||||
super.fromTag(state, tag);
|
||||
hasSeed = tag.getBoolean("HasSeed");
|
||||
seed = tag.getLong("Seed");
|
||||
generated = tag.getBoolean("Generated");
|
||||
}
|
||||
|
||||
public void generate() {
|
||||
if (hasWorld() && !Objects.requireNonNull(getWorld()).isClient() && !generated) {
|
||||
if (!hasSeed) {
|
||||
seed = getWorld().random.nextLong();
|
||||
}
|
||||
|
||||
Direction facing = getCachedState().get(StructureGeneratorBlock.HORIZONTAL_FACING);
|
||||
generated = true;
|
||||
new StructurePlacer(factory.create(getWorld(), new Random(seed), Collections.singletonList(StructurePart.directionToTransformation(facing)))).place(getWorld(), getPos());
|
||||
|
@ -11,6 +11,6 @@ public class ForcefieldBlock extends AbstractFieldBlock {
|
||||
|
||||
@Override
|
||||
protected BlockState getProjectorBlockState() {
|
||||
return EnergonRelics.FORCEFIELD_PROJECTOR_BLOCK.getDefaultState();
|
||||
return EnergonRelics.Blocks.FORCEFIELD_PROJECTOR.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ import com.thebrokenrail.energonrelics.block.forcefield.util.FieldProjectorBlock
|
||||
|
||||
public class ForcefieldProjectorBlock extends FieldProjectorBlock {
|
||||
public ForcefieldProjectorBlock() {
|
||||
super(state -> EnergonRelics.FORCEFIELD_BLOCK);
|
||||
super(state -> EnergonRelics.Blocks.FORCEFIELD);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class TractorBeamProjectorBlock extends FieldProjectorBlock {
|
||||
public static final BooleanProperty IS_REPULSOR = BooleanProperty.of("is_repulsor");
|
||||
|
||||
public TractorBeamProjectorBlock() {
|
||||
super(state -> state.get(IS_REPULSOR) ? EnergonRelics.REPULSOR_BEAM_BLOCK : EnergonRelics.TRACTOR_BEAM_BLOCK);
|
||||
super(state -> state.get(IS_REPULSOR) ? EnergonRelics.Blocks.REPULSOR_BEAM : EnergonRelics.Blocks.TRACTOR_BEAM);
|
||||
setDefaultState(getDefaultState().with(IS_REPULSOR, false));
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class IndustrialLaserBlock extends AbstractFieldBlock {
|
||||
|
||||
@Override
|
||||
protected BlockState getProjectorBlockState() {
|
||||
return EnergonRelics.INDUSTRIAL_LASER_PROJECTOR_BLOCK.getDefaultState();
|
||||
return EnergonRelics.Blocks.INDUSTRIAL_LASER_PROJECTOR.getDefaultState();
|
||||
}
|
||||
|
||||
private static class IndustrialLaserDamageSource extends DamageSource {
|
||||
@ -47,7 +47,11 @@ public class IndustrialLaserBlock extends AbstractFieldBlock {
|
||||
if (entity instanceof CreeperEntity) {
|
||||
((CreeperEntity) entity).ignite();
|
||||
} else if (entity instanceof LivingEntity) {
|
||||
entity.damage(DAMAGE_SOURCE, HardcodedConfig.INDUSTRIAL_LASER_BEAM_DAMAGE);
|
||||
if (!entity.isFireImmune()) {
|
||||
entity.setOnFireFor(8);
|
||||
|
||||
entity.damage(DAMAGE_SOURCE, HardcodedConfig.INDUSTRIAL_LASER_BEAM_DAMAGE);
|
||||
}
|
||||
} else if (entity instanceof ItemEntity) {
|
||||
ItemStack stack = ((ItemEntity) entity).getStack();
|
||||
if (stack.getItem() == Items.GUNPOWDER) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.thebrokenrail.energonrelics.block.forcefield.laser;
|
||||
|
||||
import com.thebrokenrail.energonrelics.block.entity.forcefield.laser.IndustrialLaserBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.block.entity.forcefield.laser.IndustrialLaserProjectorBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.block.forcefield.util.FieldProjectorBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
@ -14,6 +14,6 @@ public class IndustrialLaserProjectorBlock extends FieldProjectorBlock {
|
||||
|
||||
@Override
|
||||
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
|
||||
return IndustrialLaserBlockEntity::new;
|
||||
return IndustrialLaserProjectorBlockEntity::new;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public abstract class AbstractFieldBlock extends SimpleBlock {
|
||||
public static final DirectionProperty FACING = Properties.FACING;
|
||||
|
||||
public AbstractFieldBlock(boolean hasCollision) {
|
||||
super((hasCollision ? FabricBlockSettings.of(EnergonRelics.FIELD_MATERIAL) : FabricBlockSettings.of(EnergonRelics.FIELD_MATERIAL).noCollision()).strength(-1.0F, 3600000.8F).dropsNothing().nonOpaque().lightLevel(4).emissiveLighting((state, world, pos) -> true).nonOpaque().sounds(BlockSoundGroup.GLASS).allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> false).blockVision((state, world, pos) -> false));
|
||||
super((hasCollision ? FabricBlockSettings.of(EnergonRelics.Extras.FIELD_MATERIAL) : FabricBlockSettings.of(EnergonRelics.Extras.FIELD_MATERIAL).noCollision()).strength(-1.0F, 3600000.8F).dropsNothing().nonOpaque().lightLevel(4).emissiveLighting((state, world, pos) -> true).nonOpaque().sounds(BlockSoundGroup.GLASS).allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> hasCollision).blockVision((state, world, pos) -> false));
|
||||
setDefaultState(getDefaultState().with(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class BeamBlock extends AbstractFieldBlock {
|
||||
|
||||
@Override
|
||||
protected BlockState getProjectorBlockState() {
|
||||
return EnergonRelics.TRACTOR_BEAM_PROJECTOR_BLOCK.getDefaultState().with(TractorBeamProjectorBlock.IS_REPULSOR, isRepulsor);
|
||||
return EnergonRelics.Blocks.TRACTOR_BEAM_PROJECTOR.getDefaultState().with(TractorBeamProjectorBlock.IS_REPULSOR, isRepulsor);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -70,7 +70,7 @@ public class LightningRodBaseBlock extends EnergyBlock {
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||
boolean valid = true;
|
||||
if (direction == Direction.UP && (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || newState.get(LightningRodBlock.HALF) != DoubleBlockHalf.LOWER)) {
|
||||
if (direction == Direction.UP && (newState.getBlock() != EnergonRelics.Blocks.LIGHTNING_ROD || newState.get(LightningRodBlock.HALF) != DoubleBlockHalf.LOWER)) {
|
||||
valid = false;
|
||||
}
|
||||
|
||||
@ -85,8 +85,8 @@ public class LightningRodBaseBlock extends EnergyBlock {
|
||||
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
|
||||
super.onPlaced(world, pos, state, placer, itemStack);
|
||||
|
||||
world.setBlockState(pos.up(2), EnergonRelics.LIGHTNING_ROD_BLOCK.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.UPPER));
|
||||
world.setBlockState(pos.up(1), EnergonRelics.LIGHTNING_ROD_BLOCK.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.LOWER));
|
||||
world.setBlockState(pos.up(2), EnergonRelics.Blocks.LIGHTNING_ROD.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.UPPER));
|
||||
world.setBlockState(pos.up(1), EnergonRelics.Blocks.LIGHTNING_ROD.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.LOWER));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +30,7 @@ public class LightningRodBlock extends SimpleBlock {
|
||||
public static final EnumProperty<DoubleBlockHalf> HALF = Properties.DOUBLE_BLOCK_HALF;
|
||||
|
||||
public LightningRodBlock() {
|
||||
super(FabricBlockSettings.copy(EnergonRelics.LIGHTNING_ROD_BASE_BLOCK).dropsNothing().emissiveLighting((state, world, pos) -> true).lightLevel(state -> 10));
|
||||
super(FabricBlockSettings.copy(EnergonRelics.Blocks.LIGHTNING_ROD_BASE).dropsNothing().emissiveLighting((state, world, pos) -> true).lightLevel(state -> 10));
|
||||
setDefaultState(getDefaultState().with(HALF, DoubleBlockHalf.LOWER));
|
||||
}
|
||||
|
||||
@ -91,16 +91,16 @@ public class LightningRodBlock extends SimpleBlock {
|
||||
|
||||
if (state.get(HALF) == DoubleBlockHalf.LOWER) {
|
||||
if (direction == Direction.UP) {
|
||||
if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || newState.get(HALF) != DoubleBlockHalf.UPPER) {
|
||||
if (newState.getBlock() != EnergonRelics.Blocks.LIGHTNING_ROD || newState.get(HALF) != DoubleBlockHalf.UPPER) {
|
||||
valid = false;
|
||||
}
|
||||
} else if (direction == Direction.DOWN) {
|
||||
if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BASE_BLOCK) {
|
||||
if (newState.getBlock() != EnergonRelics.Blocks.LIGHTNING_ROD_BASE) {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
} else if (state.get(HALF) == DoubleBlockHalf.UPPER && direction == Direction.DOWN) {
|
||||
if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || newState.get(HALF) != DoubleBlockHalf.LOWER) {
|
||||
if (newState.getBlock() != EnergonRelics.Blocks.LIGHTNING_ROD || newState.get(HALF) != DoubleBlockHalf.LOWER) {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
@ -120,7 +120,7 @@ public class LightningRodBlock extends SimpleBlock {
|
||||
|
||||
BlockState targetState = world.getBlockState(targetPos);
|
||||
|
||||
if (targetState.getBlock() == EnergonRelics.LIGHTNING_ROD_BASE_BLOCK) {
|
||||
if (targetState.getBlock() == EnergonRelics.Blocks.LIGHTNING_ROD_BASE) {
|
||||
world.breakBlock(targetPos, false, player);
|
||||
}
|
||||
}
|
||||
@ -130,6 +130,6 @@ public class LightningRodBlock extends SimpleBlock {
|
||||
|
||||
@Override
|
||||
public Item asItem() {
|
||||
return EnergonRelics.LIGHTNING_ROD_BASE_BLOCK.asItem();
|
||||
return EnergonRelics.Blocks.LIGHTNING_ROD_BASE.asItem();
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class EnergizedObsidianBlock extends SimpleBlock {
|
||||
|
||||
private static boolean faces(WorldAccess world, BlockPos targetPos, BlockPos pos) {
|
||||
BlockState state = world.getBlockState(targetPos);
|
||||
if ((state.getBlock() == EnergonRelics.ENERGY_BEAM_BLOCK || state.getBlock() == EnergonRelics.ENERGY_PROJECTOR_BLOCK) && state.contains(Properties.FACING)) {
|
||||
if ((state.getBlock() == EnergonRelics.Blocks.ENERGY_BEAM || state.getBlock() == EnergonRelics.Blocks.ENERGY_PROJECTOR) && state.contains(Properties.FACING)) {
|
||||
Direction facing = state.get(Properties.FACING);
|
||||
for (Direction side : Direction.values()) {
|
||||
if (targetPos.offset(side).equals(pos)) {
|
||||
|
@ -11,6 +11,6 @@ public class EnergyBeamBlock extends AbstractFieldBlock {
|
||||
|
||||
@Override
|
||||
protected BlockState getProjectorBlockState() {
|
||||
return EnergonRelics.ENERGY_PROJECTOR_BLOCK.getDefaultState();
|
||||
return EnergonRelics.Blocks.ENERGY_PROJECTOR.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,12 @@ import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.function.BooleanBiFunction;
|
||||
@ -27,7 +29,7 @@ import java.util.Random;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class EnergyPortalBlock extends SimpleBlock {
|
||||
public EnergyPortalBlock() {
|
||||
super(FabricBlockSettings.copy(Blocks.NETHER_PORTAL).dropsNothing().emissiveLighting((state, world, pos) -> true).noCollision());
|
||||
super(FabricBlockSettings.of(Material.PORTAL).strength(-1f, 3600000.8f).lightLevel(11).sounds(BlockSoundGroup.GLASS).dropsNothing().emissiveLighting((state, world, pos) -> true).noCollision());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -47,7 +49,7 @@ public class EnergyPortalBlock extends SimpleBlock {
|
||||
}
|
||||
|
||||
private static boolean isObsidian(BlockState state) {
|
||||
return state.getBlock() == Blocks.OBSIDIAN || state.getBlock() == EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK;
|
||||
return state.getBlock() == Blocks.OBSIDIAN || state.getBlock() == EnergonRelics.Blocks.ENERGIZED_OBSIDIAN;
|
||||
}
|
||||
|
||||
public static boolean isValidFrame(WorldAccess world, BlockPos centerPos) {
|
||||
@ -56,7 +58,7 @@ public class EnergyPortalBlock extends SimpleBlock {
|
||||
if (isValidDirection(side)) {
|
||||
BlockPos energizedPos = centerPos.offset(side, 2);
|
||||
BlockState energizedObsidian = world.getBlockState(energizedPos);
|
||||
if (energizedObsidian.getBlock() == EnergonRelics.ENERGIZED_OBSIDIAN_BLOCK) {
|
||||
if (energizedObsidian.getBlock() == EnergonRelics.Blocks.ENERGIZED_OBSIDIAN) {
|
||||
BlockState obsidian1 = world.getBlockState(energizedPos.offset(side.rotateYClockwise(), 1));
|
||||
BlockState obsidian2 = world.getBlockState(energizedPos.offset(side.rotateYCounterclockwise(), 1));
|
||||
if (isObsidian(obsidian1) && isObsidian(obsidian2)) {
|
||||
@ -72,7 +74,7 @@ public class EnergyPortalBlock extends SimpleBlock {
|
||||
BlockPos centerPos = pos;
|
||||
for (Direction side : Direction.values()) {
|
||||
if (isValidDirection(side)) {
|
||||
if (world.getBlockState(pos.offset(side)).getBlock() != EnergonRelics.ENERGY_PORTAL_BLOCK) {
|
||||
if (world.getBlockState(pos.offset(side)).getBlock() != EnergonRelics.Blocks.ENERGY_PORTAL) {
|
||||
centerPos = centerPos.offset(side.getOpposite());
|
||||
}
|
||||
}
|
||||
@ -85,7 +87,7 @@ public class EnergyPortalBlock extends SimpleBlock {
|
||||
BlockPos startPos = centerPos.add(-1, 0, -1);
|
||||
for (int x = 0; x < 3; x++) {
|
||||
for (int z = 0; z < 3; z++) {
|
||||
if (world.getBlockState(startPos.add(x, 0, z)).getBlock() != EnergonRelics.ENERGY_PORTAL_BLOCK) {
|
||||
if (world.getBlockState(startPos.add(x, 0, z)).getBlock() != EnergonRelics.Blocks.ENERGY_PORTAL) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
@ -99,7 +101,7 @@ public class EnergyPortalBlock extends SimpleBlock {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
for (int z = 0; z < 3; z++) {
|
||||
BlockState state = world.getBlockState(startPos.add(x, 0, z));
|
||||
if (state.getBlock() != EnergonRelics.ENERGY_PORTAL_BLOCK && !state.isAir()) {
|
||||
if (state.getBlock() != EnergonRelics.Blocks.ENERGY_PORTAL && !state.isAir()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -107,7 +109,7 @@ public class EnergyPortalBlock extends SimpleBlock {
|
||||
|
||||
for (int x = 0; x < 3; x++) {
|
||||
for (int z = 0; z < 3; z++) {
|
||||
world.setBlockState(startPos.add(x, 0, z), EnergonRelics.ENERGY_PORTAL_BLOCK.getDefaultState(), 3 | 16);
|
||||
world.setBlockState(startPos.add(x, 0, z), EnergonRelics.Blocks.ENERGY_PORTAL.getDefaultState(), 3 | 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -140,11 +142,13 @@ public class EnergyPortalBlock extends SimpleBlock {
|
||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
||||
super.onEntityCollision(state, world, pos, entity);
|
||||
|
||||
if (!world.isClient() && !entity.hasVehicle() && entity.canUsePortals() && VoxelShapes.matchesAnywhere(VoxelShapes.cuboid(entity.getBoundingBox().offset(-pos.getX(), -pos.getY(), -pos.getZ())), state.getOutlineShape(world, pos), BooleanBiFunction.AND)) {
|
||||
World entityWorld = entity.getEntityWorld();
|
||||
|
||||
if (entityWorld == world && !entityWorld.isClient() && !entity.hasVehicle() && entity.canUsePortals() && VoxelShapes.matchesAnywhere(VoxelShapes.cuboid(entity.getBoundingBox().offset(-pos.getX(), -pos.getY(), -pos.getZ())), state.getOutlineShape(entityWorld, pos), BooleanBiFunction.AND)) {
|
||||
boolean cooling = ((PortalCooldownEntity) entity).isEnergyPortalCooldown();
|
||||
((PortalCooldownEntity) entity).resetEnergyPortalCooldown();
|
||||
if (!cooling) {
|
||||
EnergyTeleporter.teleport((ServerWorld) world, entity.getPos(), pos, entity);
|
||||
EnergyTeleporter.teleport((ServerWorld) entityWorld, entity.getPos(), pos, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.thebrokenrail.energonrelics.block.portal;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import com.thebrokenrail.energonrelics.mixin.ServerPlayerEntityAccessor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@ -13,20 +14,25 @@ import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.UUID;
|
||||
|
||||
class EnergyTeleporter {
|
||||
private static void teleport(Entity entity, ServerWorld to, Vec3d pos) {
|
||||
if (entity instanceof ServerPlayerEntity) {
|
||||
((ServerPlayerEntityAccessor) entity).setInTeleportationState(true);
|
||||
}
|
||||
try {
|
||||
TeleportCommand.teleport(null, entity, to, pos.getX(), pos.getY(), pos.getZ(), EnumSet.noneOf(PlayerPositionLookS2CPacket.Flag.class), entity.yaw, entity.pitch, null);
|
||||
} catch (CommandSyntaxException ignored) {
|
||||
} catch (CommandSyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (entity instanceof ServerPlayerEntity) {
|
||||
((ServerPlayerEntity) entity).networkHandler.syncWithPlayerPosition();
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,8 +40,6 @@ class EnergyTeleporter {
|
||||
BlockPos center = EnergyPortalBlock.getCenterPos(world, blockPos);
|
||||
Vec3d offset = pos.subtract(Vec3d.ofBottomCenter(center));
|
||||
|
||||
UUID uuid = entity.getUuid();
|
||||
|
||||
RegistryKey<World> worldKey = world.getRegistryKey();
|
||||
if (worldKey == World.OVERWORLD) {
|
||||
teleportWithMultiplier(world, entity, center, offset, World.NETHER, 1d / HardcodedConfig.ENERGY_PORTAL_MULTIPLIER);
|
||||
@ -46,38 +50,18 @@ class EnergyTeleporter {
|
||||
}
|
||||
|
||||
if (entity instanceof ServerPlayerEntity) {
|
||||
ServerPlayerEntity player = world.getServer().getPlayerManager().getPlayer(uuid);
|
||||
if (player != null) {
|
||||
player.playSound(SoundEvents.BLOCK_PORTAL_TRAVEL, SoundCategory.PLAYERS, 0.25f, world.random.nextFloat() * 0.4f + 0.8f);
|
||||
}
|
||||
((ServerPlayerEntity) entity).playSound(SoundEvents.BLOCK_PORTAL_TRAVEL, SoundCategory.PLAYERS, 0.25f, world.random.nextFloat() * 0.4f + 0.8f);
|
||||
}
|
||||
}
|
||||
|
||||
private static int convertY(int y, int oldHeight, int newHeight) {
|
||||
int bottomPadding = HardcodedConfig.ENERGY_PORTAL_Y_PADDING;
|
||||
int topPadding = bottomPadding + HardcodedConfig.ENERGY_PORTAL_Y_PADDING_EXTRA_TOP;
|
||||
int newY = (int) (((float) newHeight / (float) oldHeight) * (float) y);
|
||||
|
||||
int oldMax = oldHeight - topPadding;
|
||||
int bottomY = HardcodedConfig.ENERGY_PORTAL_Y_PADDING;
|
||||
int topY = newHeight - (bottomY + HardcodedConfig.ENERGY_PORTAL_Y_PADDING_EXTRA_TOP);
|
||||
newY = Math.max(bottomY, Math.min(topY, newY));
|
||||
|
||||
y = MathHelper.clamp(y, bottomPadding, oldMax);
|
||||
|
||||
int totalPadding = bottomPadding + topPadding;
|
||||
int oldPaddedHeight = oldHeight - totalPadding;
|
||||
int newPaddedHeight = newHeight - totalPadding;
|
||||
|
||||
float multiplier = (float) newPaddedHeight / (float) oldPaddedHeight;
|
||||
|
||||
y = y - bottomPadding;
|
||||
|
||||
y = (int) (y * multiplier);
|
||||
|
||||
int newMax = newHeight - topPadding;
|
||||
|
||||
y = y + bottomPadding;
|
||||
|
||||
y = MathHelper.clamp(y, bottomPadding, newMax);
|
||||
|
||||
return y;
|
||||
return newY;
|
||||
}
|
||||
|
||||
private static void teleportWithMultiplier(ServerWorld world, Entity entity, BlockPos center, Vec3d offset, RegistryKey<World> toKey, double multiplier) {
|
||||
|
@ -22,6 +22,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ReactorInputBlock extends SimpleBlockWithEntity {
|
||||
public ReactorInputBlock() {
|
||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.YELLOW_TERRACOTTA).requiresTool().strength(1.5f, 6.0f));
|
||||
@ -33,7 +34,6 @@ public class ReactorInputBlock extends SimpleBlockWithEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
BlockEntity entity = world.getBlockEntity(pos);
|
||||
if (entity instanceof Inventory) {
|
||||
@ -45,4 +45,9 @@ public class ReactorInputBlock extends SimpleBlockWithEntity {
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasInventory() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import com.thebrokenrail.energonrelics.block.entity.structure.StructureGenerator
|
||||
import com.thebrokenrail.energonrelics.api.block.SimpleBlockWithEntity;
|
||||
import com.thebrokenrail.energonrelics.structure.researchcomplex.ResearchComplexStartPart;
|
||||
import com.thebrokenrail.energonrelics.structure.researchcomplex.ResearchComplexState;
|
||||
import net.earthcomputer.libstructure.LibStructure;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.structure.v1.FabricStructureBuilder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@ -23,10 +23,12 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.GenerationSettings;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.chunk.StructureConfig;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
@ -98,10 +100,12 @@ public class StructureGeneratorBlock extends SimpleBlockWithEntity {
|
||||
@Override
|
||||
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) {
|
||||
super.onBlockAdded(state, world, pos, oldState, notify);
|
||||
schedule(world, pos);
|
||||
if (world instanceof ServerWorld) {
|
||||
schedule((ServerWorld) world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void schedule(World world, BlockPos pos) {
|
||||
public void schedule(StructureWorldAccess world, BlockPos pos) {
|
||||
world.getBlockTickScheduler().schedule(pos, this, 0);
|
||||
}
|
||||
|
||||
@ -116,22 +120,26 @@ public class StructureGeneratorBlock extends SimpleBlockWithEntity {
|
||||
blocks.put(name, block);
|
||||
|
||||
Registry.register(Registry.STRUCTURE_PIECE, new Identifier(EnergonRelics.NAMESPACE, name + "_piece"), block.piece);
|
||||
LibStructure.registerStructure(new Identifier(EnergonRelics.NAMESPACE, name), block.feature, GenerationStep.Feature.UNDERGROUND_STRUCTURES, block.structureConfig, block.feature.configure(FeatureConfig.DEFAULT));
|
||||
FabricStructureBuilder.create(new Identifier(EnergonRelics.NAMESPACE, name), block.feature).step(GenerationStep.Feature.UNDERGROUND_STRUCTURES).defaultConfig(block.structureConfig).superflatFeature(block.feature.configure(FeatureConfig.DEFAULT)).register();
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
public static void registerBlocks() {
|
||||
for (Map.Entry<String, StructureGeneratorBlock> entry : blocks.entrySet()) {
|
||||
entry.getValue().register(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
public static void addToBiome(GenerationSettings.Builder builder) {
|
||||
public static void addToBiome(Biome biome) {
|
||||
registerStructures();
|
||||
for (Map.Entry<String, StructureGeneratorBlock> entry : blocks.entrySet()) {
|
||||
builder.structureFeature(entry.getValue().feature.configure(DefaultFeatureConfig.INSTANCE));
|
||||
ConfiguredStructureFeature<?, ?> feature = entry.getValue().feature.configure(DefaultFeatureConfig.INSTANCE);
|
||||
biome.getGenerationSettings().getStructureFeatures().add(() -> feature);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
create("research_complex", (world, random, transformations) -> new ResearchComplexStartPart(new ResearchComplexState(world, random), transformations), new StructureConfig(32, 8, 14357618));
|
||||
public static void registerStructures() {
|
||||
if (blocks.size() == 0) {
|
||||
create("research_complex", (world, random, transformations) -> new ResearchComplexStartPart(new ResearchComplexState(world, random), transformations), new StructureConfig(32, 8, 14357618));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,17 +19,23 @@ class StructureGeneratorPiece extends StructurePiece {
|
||||
private final StructureGeneratorBlock block;
|
||||
private final BlockRotation rotation;
|
||||
private final BlockPos pos;
|
||||
private boolean placed;
|
||||
|
||||
StructureGeneratorPiece(StructureGeneratorBlock block, BlockRotation rotation, BlockPos pos) {
|
||||
private StructureGeneratorPiece(StructureGeneratorBlock block, BlockRotation rotation, BlockPos pos, boolean placed) {
|
||||
super(block.piece, 0);
|
||||
this.block = block;
|
||||
this.rotation = rotation;
|
||||
this.pos = pos;
|
||||
this.placed = placed;
|
||||
boundingBox = BlockBox.create(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
|
||||
}
|
||||
|
||||
StructureGeneratorPiece(StructureGeneratorBlock block, BlockRotation rotation, BlockPos pos) {
|
||||
this(block, rotation, pos, false);
|
||||
}
|
||||
|
||||
StructureGeneratorPiece(StructureGeneratorBlock block, CompoundTag tag) {
|
||||
this(block, BlockRotation.valueOf(tag.getString("Rot")), new BlockPos(tag.getInt("X"), tag.getInt("Y"), tag.getInt("Z")));
|
||||
this(block, BlockRotation.valueOf(tag.getString("Rot")), new BlockPos(tag.getInt("X"), tag.getInt("Y"), tag.getInt("Z")), tag.getBoolean("Placed"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,19 +44,24 @@ class StructureGeneratorPiece extends StructurePiece {
|
||||
tag.putInt("X", pos.getX());
|
||||
tag.putInt("Y", pos.getY());
|
||||
tag.putInt("Z", pos.getZ());
|
||||
tag.putBoolean("Placed", placed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos blockPos) {
|
||||
BlockState state = block.getDefaultState().rotate(rotation);
|
||||
if (!placed) {
|
||||
BlockState state = block.getDefaultState().rotate(rotation);
|
||||
|
||||
world.setBlockState(pos, state, 3);
|
||||
BlockEntity entity = world.getBlockEntity(pos);
|
||||
if (entity instanceof StructureGeneratorBlockEntity) {
|
||||
((StructureGeneratorBlockEntity) entity).setSeed(random.nextLong());
|
||||
world.setBlockState(pos, state, 3);
|
||||
BlockEntity entity = world.getBlockEntity(pos);
|
||||
if (entity instanceof StructureGeneratorBlockEntity) {
|
||||
((StructureGeneratorBlockEntity) entity).setSeed(random.nextLong());
|
||||
}
|
||||
|
||||
block.schedule(world, pos);
|
||||
|
||||
placed = true;
|
||||
}
|
||||
|
||||
block.schedule(world.toServerWorld(), pos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.thebrokenrail.energonrelics.client;
|
||||
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.block.PhaseShifterBlock;
|
||||
import com.thebrokenrail.energonrelics.block.forcefield.util.AbstractFieldBlock;
|
||||
import com.thebrokenrail.energonrelics.api.block.energy.EnergyBlock;
|
||||
import com.thebrokenrail.energonrelics.client.config.UserConfig;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
|
||||
@ -12,6 +14,7 @@ import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
||||
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
@ -40,22 +43,26 @@ public final class EnergonRelicsClient implements ClientModInitializer {
|
||||
public void onInitializeClient() {
|
||||
EnergyBlock.initRenderer();
|
||||
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.THERMAL_GLASS_BLOCK, RenderLayer.getCutout());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.DEFENSIVE_LASER_BLOCK, RenderLayer.getCutout());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.THERMAL_GLASS, RenderLayer.getCutout());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.DEFENSIVE_LASER, RenderLayer.getCutout());
|
||||
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.FORCEFIELD_BLOCK, RenderLayer.getTranslucent());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.TRACTOR_BEAM_BLOCK, RenderLayer.getTranslucent());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.REPULSOR_BEAM_BLOCK, RenderLayer.getTranslucent());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.INDUSTRIAL_LASER_BLOCK, RenderLayer.getTranslucent());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.FORCEFIELD, RenderLayer.getTranslucent());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.TRACTOR_BEAM, RenderLayer.getTranslucent());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.REPULSOR_BEAM, RenderLayer.getTranslucent());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.INDUSTRIAL_LASER, RenderLayer.getTranslucent());
|
||||
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.ENERGY_PORTAL_BLOCK, RenderLayer.getTranslucent());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.ENERGY_BEAM_BLOCK, RenderLayer.getTranslucent());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.ENERGY_PORTAL, RenderLayer.getTranslucent());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.ENERGY_BEAM, RenderLayer.getTranslucent());
|
||||
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.Blocks.PHASE_SHIFTER, RenderLayer.getCutoutMipped());
|
||||
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> state.get(PhaseShifterBlock.COLOR).getFireworkColor(), EnergonRelics.Blocks.PHASE_SHIFTER);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? HardcodedConfig.PHASE_SHIFTER_DEFAULT_COLOR.getFireworkColor() : -1);
|
||||
|
||||
AutoConfig.register(UserConfig.class, ReloadSerializer::new);
|
||||
|
||||
AttackBlockCallback.EVENT.register((playerEntity, world, hand, blockPos, direction) -> {
|
||||
BlockState state = world.getBlockState(blockPos);
|
||||
if (state.getBlock() instanceof AbstractFieldBlock || state.getBlock() == EnergonRelics.ENERGY_PORTAL_BLOCK) {
|
||||
if (state.getBlock() instanceof AbstractFieldBlock || state.getBlock() == EnergonRelics.Blocks.ENERGY_PORTAL) {
|
||||
return ActionResult.FAIL;
|
||||
} else {
|
||||
return ActionResult.PASS;
|
||||
|
@ -22,7 +22,6 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
|
||||
|
||||
@Override
|
||||
public void render(BlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||
super.render(entity, tickDelta, matrices, vertexConsumers, light, overlay);
|
||||
if (entity instanceof DefensiveLaserBlockEntity) {
|
||||
matrices.push();
|
||||
matrices.translate(0.5d, 0.5d, 0.5d);
|
||||
@ -44,7 +43,7 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
|
||||
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
client.getItemRenderer().renderItem(new ItemStack(EnergonRelics.DEFENSIVE_LASER_CORE_ITEM), ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers);
|
||||
client.getItemRenderer().renderItem(new ItemStack(EnergonRelics.Items.DEFENSIVE_LASER_CORE), ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers);
|
||||
|
||||
matrices.pop();
|
||||
|
||||
@ -61,5 +60,6 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
super.render(entity, tickDelta, matrices, vertexConsumers, light, overlay);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package com.thebrokenrail.energonrelics.client.block.entity.render;
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.mixin.RenderPhaseAccessor;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
@ -15,6 +17,7 @@ import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
@ -23,13 +26,14 @@ import net.minecraft.util.math.Matrix4f;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class HighlightBlockEntityRenderer extends BlockEntityRenderer<BlockEntity> {
|
||||
public HighlightBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
private static RenderLayer getLayer(Identifier texture) {
|
||||
return RenderLayer.of(EnergonRelics.NAMESPACE + ":highlight", VertexFormats.POSITION_COLOR, 7, 256, false, true, RenderLayer.MultiPhaseParameters.builder().transparency(RenderPhaseAccessor.getTRANSLUCENT_TRANSPARENCY()).layering(RenderPhaseAccessor.getVIEW_OFFSET_Z_LAYERING()).texture(new RenderPhase.Texture(texture, false, false)).fog(RenderPhaseAccessor.getNO_FOG()).cull(RenderPhaseAccessor.getENABLE_CULLING()).build(false));
|
||||
return RenderLayer.of(EnergonRelics.NAMESPACE + ":highlight", VertexFormats.POSITION_COLOR, 7, 256, false, true, RenderLayer.MultiPhaseParameters.builder().writeMaskState(RenderPhaseAccessor.getCOLOR_MASK()).transparency(RenderPhaseAccessor.getTRANSLUCENT_TRANSPARENCY()).layering(RenderPhaseAccessor.getVIEW_OFFSET_Z_LAYERING()).texture(new RenderPhase.Texture(texture, false, false)).fog(RenderPhaseAccessor.getNO_FOG()).cull(RenderPhaseAccessor.getENABLE_CULLING()).build(false));
|
||||
}
|
||||
|
||||
private static final RenderLayer SELECTED_LAYER = getLayer(new Identifier(EnergonRelics.NAMESPACE, "textures/entity/selected_energy_block.png"));
|
||||
@ -42,39 +46,78 @@ public class HighlightBlockEntityRenderer extends BlockEntityRenderer<BlockEntit
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
assert client.player != null;
|
||||
ItemStack stack = client.player.getStackInHand(Hand.MAIN_HAND);
|
||||
if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) {
|
||||
boolean contains = ((EnergyReceiverBlockEntity) entity).contains(EnergonRelics.NETWORK_CHIP_ITEM.getID(stack));
|
||||
Matrix4f matrix4f = matrices.peek().getModel();
|
||||
if (stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM) {
|
||||
boolean contains = ((EnergyReceiverBlockEntity) entity).contains(EnergonRelics.Items.NETWORK_CHIP_ITEM.getID(stack));
|
||||
if (!contains) {
|
||||
renderLayer(entity, matrix4f, vertexConsumers.getBuffer(UNSELECTED_LAYER));
|
||||
renderCuboid(entity, matrices, vertexConsumers.getBuffer(UNSELECTED_LAYER));
|
||||
} else {
|
||||
renderLayer(entity, matrix4f, vertexConsumers.getBuffer(SELECTED_LAYER));
|
||||
renderCuboid(entity, matrices, vertexConsumers.getBuffer(SELECTED_LAYER));
|
||||
}
|
||||
}
|
||||
}
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
private void renderLayer(BlockEntity entity, Matrix4f matrix4f, VertexConsumer vertexConsumer) {
|
||||
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 0f, 1f, 1f, 1f, 1f, 1f, Direction.SOUTH);
|
||||
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, Direction.NORTH);
|
||||
renderSide(entity, matrix4f, vertexConsumer, 1f, 1f, 1f, 0f, 0f, 1f, 1f, 0f, Direction.EAST);
|
||||
renderSide(entity, matrix4f, vertexConsumer, 0f, 0f, 0f, 1f, 0f, 1f, 1f, 0f, Direction.WEST);
|
||||
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 1f, Direction.DOWN);
|
||||
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 1f, 1f, 1f, 1f, 0f, 0f, Direction.UP);
|
||||
}
|
||||
|
||||
protected boolean shouldDrawSide(BlockEntity entity, Direction side) {
|
||||
private static boolean shouldDrawSide(BlockEntity entity, Direction side) {
|
||||
BlockState state = entity.getCachedState();
|
||||
return Block.shouldDrawSide(state, Objects.requireNonNull(entity.getWorld()), entity.getPos(), side);
|
||||
}
|
||||
|
||||
private void renderSide(BlockEntity entity, Matrix4f matrix4f, VertexConsumer vertexConsumer, float f, float g, float h, float i, float j, float k, float l, float m, Direction side) {
|
||||
if (shouldDrawSide(entity, side)) {
|
||||
vertexConsumer.vertex(matrix4f, f, h, j).color(1f, 1f, 1f, 1f).next();
|
||||
vertexConsumer.vertex(matrix4f, g, h, k).color(1f, 1f, 1f, 1f).next();
|
||||
vertexConsumer.vertex(matrix4f, g, i, l).color(1f, 1f, 1f, 1f).next();
|
||||
vertexConsumer.vertex(matrix4f, f, i, m).color(1f, 1f, 1f, 1f).next();
|
||||
protected static void renderCuboid(BlockEntity entity, MatrixStack matrices, VertexConsumer consumer) {
|
||||
float sizeX = 1f;
|
||||
float sizeY = 1f;
|
||||
float sizeZ = 1f;
|
||||
|
||||
matrices.translate(0.5d, 0.5d, 0.5d);
|
||||
|
||||
for (Direction side : Direction.values()) {
|
||||
if (shouldDrawSide(entity, side)) {
|
||||
matrices.push();
|
||||
|
||||
multiply(matrices, side);
|
||||
|
||||
Matrix4f model = matrices.peek().getModel();
|
||||
|
||||
vertex(consumer, model, -0.5f, -0.5f, -0.5f);
|
||||
vertex(consumer, model, -0.5f, -0.5f + sizeY, -0.5f);
|
||||
vertex(consumer, model, -0.5f + sizeX, -0.5f + sizeY, -0.5f);
|
||||
vertex(consumer, model, -0.5f + sizeX, -0.5f, -0.5f);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static void vertex(VertexConsumer consumer, Matrix4f model, float x, float y, float z) {
|
||||
consumer.vertex(model, x, y, z).color(1f, 1f, 1f, 1f).next();
|
||||
}
|
||||
|
||||
private static void multiply(MatrixStack matrices, Direction side) {
|
||||
switch (side) {
|
||||
case NORTH: {
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180));
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90));
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90));
|
||||
break;
|
||||
}
|
||||
case UP: {
|
||||
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90));
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-90));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,10 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gl.Framebuffer;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.RenderPhase;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@ -69,27 +67,9 @@ public class HolographicSkyBlockEntityRenderer extends HighlightBlockEntityRende
|
||||
if (entity instanceof HolographicSkyBlockEntity && entity.getCachedState().get(HolographicSkyBlock.POWERED)) {
|
||||
matrixStack.push();
|
||||
Matrix4f matrix4f = matrixStack.peek().getModel();
|
||||
renderLayer((HolographicSkyBlockEntity) entity, matrix4f, vertexConsumerProvider.getBuffer(LAYER));
|
||||
renderCuboid(entity, matrixStack, vertexConsumerProvider.getBuffer(LAYER));
|
||||
matrixStack.pop();
|
||||
}
|
||||
super.render(entity, f, matrixStack, vertexConsumerProvider, i, j);
|
||||
}
|
||||
|
||||
private void renderLayer(HolographicSkyBlockEntity entity, Matrix4f matrix4f, VertexConsumer vertexConsumer) {
|
||||
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 0f, 1f, 1f, 1f, 1f, 1f, Direction.SOUTH);
|
||||
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 1f, 0f, 0f, 0f, 0f, 0f, Direction.NORTH);
|
||||
renderSide(entity, matrix4f, vertexConsumer, 1f, 1f, 1f, 0f, 0f, 1f, 1f, 0f, Direction.EAST);
|
||||
renderSide(entity, matrix4f, vertexConsumer, 0f, 0f, 0f, 1f, 0f, 1f, 1f, 0f, Direction.WEST);
|
||||
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 1f, Direction.DOWN);
|
||||
renderSide(entity, matrix4f, vertexConsumer, 0f, 1f, 1f, 1f, 1f, 1f, 0f, 0f, Direction.UP);
|
||||
}
|
||||
|
||||
private void renderSide(HolographicSkyBlockEntity entity, Matrix4f matrix4f, VertexConsumer vertexConsumer, float f, float g, float h, float i, float j, float k, float l, float m, Direction side) {
|
||||
if (shouldDrawSide(entity, side)) {
|
||||
vertexConsumer.vertex(matrix4f, f, h, j).color(1f, 1f, 1f, 1f).next();
|
||||
vertexConsumer.vertex(matrix4f, g, h, k).color(1f, 1f, 1f, 1f).next();
|
||||
vertexConsumer.vertex(matrix4f, g, i, l).color(1f, 1f, 1f, 1f).next();
|
||||
vertexConsumer.vertex(matrix4f, f, i, m).color(1f, 1f, 1f, 1f).next();
|
||||
}
|
||||
}
|
||||
}
|
@ -3,13 +3,19 @@ package com.thebrokenrail.energonrelics.client.rei;
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.client.rei.infuser.InfuserCategory;
|
||||
import com.thebrokenrail.energonrelics.client.rei.reactor.ReactorFuelCategory;
|
||||
import me.shedaniel.rei.api.BuiltinPlugin;
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeHelper;
|
||||
import me.shedaniel.rei.api.plugins.REIPluginV0;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public final class EnergonRelicsPlugin implements REIPluginV0 {
|
||||
public static final Identifier INFUSING = new Identifier(EnergonRelics.NAMESPACE, "plugin/infusing");
|
||||
@ -22,11 +28,17 @@ public final class EnergonRelicsPlugin implements REIPluginV0 {
|
||||
|
||||
@Override
|
||||
public void registerOthers(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerWorkingStations(INFUSING, EntryStack.create(EnergonRelics.INFUSER_BLOCK));
|
||||
recipeHelper.registerWorkingStations(REACTOR_FUEL, EntryStack.create(EnergonRelics.REACTOR_INPUT_BLOCK));
|
||||
recipeHelper.registerWorkingStations(INFUSING, EntryStack.create(EnergonRelics.Blocks.INFUSER));
|
||||
recipeHelper.registerWorkingStations(REACTOR_FUEL, EntryStack.create(EnergonRelics.Blocks.REACTOR_INPUT));
|
||||
|
||||
recipeHelper.removeAutoCraftButton(INFUSING);
|
||||
recipeHelper.removeAutoCraftButton(REACTOR_FUEL);
|
||||
|
||||
BuiltinPlugin.getInstance().registerInformation(EntryStack.create(EnergonRelics.Items.CIRCUIT_BOARD), new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".information.structure_generation.title"), texts -> {
|
||||
List<Text> newTexts = new ArrayList<>(texts);
|
||||
newTexts.add(new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".information.structure_generation.research_complex"));
|
||||
return newTexts;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +66,7 @@ public class InfuserCategory implements RecipeCategory<InfuserDisplay> {
|
||||
|
||||
@Override
|
||||
public EntryStack getLogo() {
|
||||
return EntryStack.create(EnergonRelics.INFUSER_BLOCK);
|
||||
return EntryStack.create(EnergonRelics.Blocks.INFUSER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +54,7 @@ public class ReactorFuelCategory implements RecipeCategory<ReactorFuelDisplay> {
|
||||
|
||||
@Override
|
||||
public EntryStack getLogo() {
|
||||
return EntryStack.create(EnergonRelics.REACTOR_INPUT_BLOCK);
|
||||
return EntryStack.create(EnergonRelics.Blocks.REACTOR_INPUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,7 @@ package com.thebrokenrail.energonrelics.config;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.DyeColor;
|
||||
|
||||
/**
|
||||
* Hardcoded Configuration Values
|
||||
@ -9,14 +10,16 @@ import net.minecraft.item.Items;
|
||||
public final class HardcodedConfig {
|
||||
public static final int POWER_RANGE = 64;
|
||||
|
||||
public static final long SWITCH_ENERGY_REQUIRED = 2;
|
||||
|
||||
public static final int ENERGON_LIGHT_ENERGY_REQUIRED = 5;
|
||||
|
||||
public static final long SOLAR_PANEL_MAX_ENERGY_OUTPUT = 50;
|
||||
public static final long SOLAR_PANEL_MAX_ENERGY_OUTPUT = 70;
|
||||
|
||||
public static final long BATTERY_CHARGE_RATE = 40;
|
||||
|
||||
public static final int REACTOR_TIME = 2400;
|
||||
public static final int REACTOR_ENERGY_OUTPUT = 250;
|
||||
public static final int REACTOR_ENERGY_OUTPUT = 350;
|
||||
|
||||
public static final int DEFENSIVE_LASER_RANGE = 28;
|
||||
public static final long DEFENSIVE_LASER_IDLE_ENERGY_REQUIRED = 32;
|
||||
@ -53,4 +56,15 @@ public final class HardcodedConfig {
|
||||
public static final int ENERGY_PORTAL_MULTIPLIER = 16;
|
||||
public static final int ENERGY_PORTAL_Y_PADDING = 4;
|
||||
public static final int ENERGY_PORTAL_Y_PADDING_EXTRA_TOP = 3;
|
||||
|
||||
public static final long PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_BASE = 112;
|
||||
public static final long PHASE_SHIFTER_INPUT_ENERGY_REQUIRED_PER_ITEM = 19;
|
||||
public static final int PHASE_SHIFTER_INPUT_COOLDOWN = 16;
|
||||
public static final int PHASE_SHIFTER_INPUT_ROLL_COOLDOWN = 6;
|
||||
public static final int PHASE_SHIFTER_INPUT_RANGE_BASE = 21;
|
||||
public static final int PHASE_SHIFTER_INPUT_RANGE_INCREMENT = 9;
|
||||
public static final float PHASE_SHIFTER_SUCCESS_CHANCE = 0.1f;
|
||||
public static final long PHASE_SHIFTER_OUTPUT_ENERGY_REQUIRED = 28;
|
||||
public static final int PHASE_SHIFTER_OUTPUT_COOLDOWN = 21;
|
||||
public static final DyeColor PHASE_SHIFTER_DEFAULT_COLOR = DyeColor.WHITE;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.thebrokenrail.energonrelics.feature;
|
||||
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||
|
||||
public class CustomFeatures {
|
||||
public static final ConfiguredFeature<?, ?> VERIDIUM_ORE_FEATURE = Feature.ORE.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, EnergonRelics.Blocks.VERIDIUM_ORE.getDefaultState(), 9)).method_30377(32).spreadHorizontally().repeat(2);
|
||||
|
||||
public static void register() {
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(EnergonRelics.NAMESPACE, "veridium_ore"), VERIDIUM_ORE_FEATURE);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package com.thebrokenrail.energonrelics.item;
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.api.block.entity.core.EnergyReceiverBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.api.block.entity.helper.EnergyGenerator;
|
||||
import com.thebrokenrail.energonrelics.api.item.MultimeterExtra;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
@ -18,11 +19,7 @@ import java.util.Objects;
|
||||
|
||||
public class MultimeterItem extends Item {
|
||||
public MultimeterItem() {
|
||||
super(new Settings().maxCount(1).group(EnergonRelics.ITEM_GROUP));
|
||||
}
|
||||
|
||||
public interface MultimeterExtra {
|
||||
MutableText getExtra();
|
||||
super(new Settings().maxCount(1).group(EnergonRelics.Items.ITEM_GROUP));
|
||||
}
|
||||
|
||||
public static MutableText format(long value) {
|
||||
@ -61,10 +58,13 @@ public class MultimeterItem extends Item {
|
||||
}
|
||||
if (entity instanceof MultimeterExtra) {
|
||||
if (!world.isClient() && context.getPlayer() != null) {
|
||||
if (success) {
|
||||
text.append(separator);
|
||||
MutableText extraText = ((MultimeterExtra) entity).getExtra();
|
||||
if (extraText != null) {
|
||||
if (success) {
|
||||
text.append(separator);
|
||||
}
|
||||
text.append(extraText.formatted(Formatting.YELLOW));
|
||||
}
|
||||
text.append(((MultimeterExtra) entity).getExtra().formatted(Formatting.YELLOW));
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
@ -72,7 +72,7 @@ public class MultimeterItem extends Item {
|
||||
if (!world.isClient()) {
|
||||
Objects.requireNonNull(context.getPlayer()).sendMessage(text, true);
|
||||
}
|
||||
EnergonRelics.playBeep(world, context.getBlockPos());
|
||||
EnergonRelics.Extras.playBeep(world, context.getBlockPos());
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
return ActionResult.PASS;
|
||||
|
@ -24,7 +24,7 @@ import java.util.List;
|
||||
|
||||
public class NetworkChipItem extends Item {
|
||||
public NetworkChipItem() {
|
||||
super(new Settings().maxCount(1).group(EnergonRelics.ITEM_GROUP));
|
||||
super(new Settings().maxCount(1).group(EnergonRelics.Items.ITEM_GROUP));
|
||||
}
|
||||
|
||||
private void setID(ItemStack stack, int id) {
|
||||
@ -86,7 +86,7 @@ public class NetworkChipItem extends Item {
|
||||
NetworkComponent component = NetworkComponent.getInstance(serverWorld);
|
||||
((EnergyReceiverBlockEntity) entity).toggle(getOrCreateID(context.getStack(), component));
|
||||
}
|
||||
EnergonRelics.playBeep(world, context.getBlockPos());
|
||||
EnergonRelics.Extras.playBeep(world, context.getBlockPos());
|
||||
return ActionResult.SUCCESS;
|
||||
} else {
|
||||
return ActionResult.PASS;
|
||||
|
@ -1,13 +0,0 @@
|
||||
package com.thebrokenrail.energonrelics.mixin;
|
||||
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(DamageSource.class)
|
||||
public interface DamageSourceAccessor {
|
||||
@Invoker
|
||||
static DamageSource createDamageSource(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.thebrokenrail.energonrelics.mixin;
|
||||
|
||||
import net.minecraft.world.biome.GenerationSettings;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mixin(GenerationSettings.class)
|
||||
public interface GenerationSettingsAccessor {
|
||||
@Accessor
|
||||
List<Supplier<ConfiguredStructureFeature<?, ?>>> getStructureFeatures();
|
||||
|
||||
@Mutable
|
||||
@Accessor
|
||||
void setStructureFeatures(List<Supplier<ConfiguredStructureFeature<?, ?>>> structureFeatures);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.thebrokenrail.energonrelics.mixin;
|
||||
|
||||
import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock;
|
||||
import net.minecraft.Bootstrap;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Bootstrap.class)
|
||||
public class MixinBootstrap {
|
||||
@Inject(at = @At("TAIL"), method = "initialize")
|
||||
private static void initialize(CallbackInfo info) {
|
||||
StructureGeneratorBlock.registerStructures();
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.thebrokenrail.energonrelics.mixin;
|
||||
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock;
|
||||
import com.thebrokenrail.energonrelics.feature.CustomFeatures;
|
||||
import net.minecraft.world.biome.GenerationSettings;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.feature.DefaultBiomeFeatures;
|
||||
@ -14,11 +13,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public class MixinDefaultBiomeFeatures {
|
||||
@Inject(at = @At("RETURN"), method = "addDefaultOres")
|
||||
private static void addDefaultOres(GenerationSettings.Builder builder, CallbackInfo info) {
|
||||
builder.feature(GenerationStep.Feature.UNDERGROUND_ORES, EnergonRelics.VERIDIUM_ORE_FEATURE);
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "addDefaultUndergroundStructures")
|
||||
private static void addDefaultUndergroundStructures(GenerationSettings.Builder builder, CallbackInfo info) {
|
||||
StructureGeneratorBlock.addToBiome(builder);
|
||||
builder.feature(GenerationStep.Feature.UNDERGROUND_ORES, CustomFeatures.VERIDIUM_ORE_FEATURE);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.thebrokenrail.energonrelics.block.forcefield.util.BeamBlock;
|
||||
import com.thebrokenrail.energonrelics.block.portal.PortalCooldownEntity;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@ -26,6 +27,8 @@ import java.util.function.Predicate;
|
||||
public abstract class MixinEntity implements PortalCooldownEntity {
|
||||
@Unique
|
||||
private int energyPortalCooldown = 0;
|
||||
@Unique
|
||||
private boolean touchingBeam = false;
|
||||
|
||||
@Shadow
|
||||
public abstract Box getBoundingBox();
|
||||
@ -53,7 +56,8 @@ public abstract class MixinEntity implements PortalCooldownEntity {
|
||||
for (int q = k; q < l; ++q) {
|
||||
for (int r = m; r < n; ++r) {
|
||||
pos.set(p, q, r);
|
||||
if (test.test(getEntityWorld().getBlockState(pos).getBlock())) {
|
||||
BlockState state = getEntityWorld().getBlockState(pos);
|
||||
if (state.getCollisionShape(getEntityWorld(), pos).isEmpty() && test.test(state.getBlock())) {
|
||||
getEntityWorld().getProfiler().pop();
|
||||
return true;
|
||||
}
|
||||
@ -71,7 +75,7 @@ public abstract class MixinEntity implements PortalCooldownEntity {
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "hasNoGravity", cancellable = true)
|
||||
public void hasNoGravity(CallbackInfoReturnable<Boolean> info) {
|
||||
if (!saving && isTouching(block -> block instanceof BeamBlock)) {
|
||||
if (!saving && touchingBeam) {
|
||||
info.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
@ -92,8 +96,13 @@ public abstract class MixinEntity implements PortalCooldownEntity {
|
||||
energyPortalCooldown = tag.getInt(EnergonRelics.NAMESPACE + ":EnergyPortalCooldown");
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "tick")
|
||||
public void tickHead(CallbackInfo info) {
|
||||
touchingBeam = isTouching(block -> block instanceof BeamBlock);
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "tick")
|
||||
public void tick(CallbackInfo info) {
|
||||
public void tickReturn(CallbackInfo info) {
|
||||
energyPortalCooldown--;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,47 @@
|
||||
package com.thebrokenrail.energonrelics.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfileRepository;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock;
|
||||
import net.minecraft.resource.ResourcePackManager;
|
||||
import net.minecraft.resource.ServerResourceManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.WorldGenerationProgressListenerFactory;
|
||||
import net.minecraft.util.UserCache;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.SaveProperties;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import net.minecraft.world.level.storage.LevelStorage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.net.Proxy;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MixinMinecraftServer {
|
||||
@Shadow
|
||||
@Final
|
||||
protected DynamicRegistryManager.Impl registryManager;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "<init>")
|
||||
private void init(Thread thread, DynamicRegistryManager.Impl impl, LevelStorage.Session session, SaveProperties saveProperties, ResourcePackManager resourcePackManager, Proxy proxy, DataFixer dataFixer, ServerResourceManager serverResourceManager, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, UserCache userCache, WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory, CallbackInfo info) {
|
||||
if (registryManager.getOptional(Registry.BIOME_KEY).isPresent()) {
|
||||
for (Biome biome : registryManager.getOptional(Registry.BIOME_KEY).get()) {
|
||||
// Make Mutable
|
||||
((GenerationSettingsAccessor) biome.getGenerationSettings()).setStructureFeatures(new ArrayList<>(((GenerationSettingsAccessor) biome.getGenerationSettings()).getStructureFeatures()));
|
||||
|
||||
if (biome.getGenerationSettings().hasStructureFeature(StructureFeature.MINESHAFT)) {
|
||||
StructureGeneratorBlock.addToBiome(biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -25,4 +25,9 @@ public interface RenderPhaseAccessor {
|
||||
static RenderPhase.Cull getENABLE_CULLING() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Accessor
|
||||
static RenderPhase.WriteMaskState getCOLOR_MASK() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.thebrokenrail.energonrelics.mixin;
|
||||
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ServerPlayerEntity.class)
|
||||
public interface ServerPlayerEntityAccessor {
|
||||
@Accessor
|
||||
void setInTeleportationState(boolean inTeleportationState);
|
||||
}
|
@ -50,7 +50,7 @@ public class CustomPotions {
|
||||
}
|
||||
|
||||
private static void registerBrewingRecipes() {
|
||||
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EnergonRelics.VERIDIUM_POWDER_ITEM, VERIDIUM_POISON_EFFECT.potion);
|
||||
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(Potions.AWKWARD, EnergonRelics.Items.VERIDIUM_POWDER, VERIDIUM_POISON_EFFECT.potion);
|
||||
BrewingRecipeRegistryAccessor.callRegisterPotionRecipe(VERIDIUM_POISON_EFFECT.potion, Items.REDSTONE, VERIDIUM_POISON_EFFECT.longPotion);
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,9 @@ public class DuplicateNetworkChipRecipe extends SpecialCraftingRecipe {
|
||||
boolean foundCircuit = false;
|
||||
for (int i = 0; i < inv.size(); i++) {
|
||||
ItemStack stack = inv.getStack(i);
|
||||
if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM && !foundChip) {
|
||||
if (stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM && !foundChip) {
|
||||
foundChip = true;
|
||||
} else if (stack.getItem() == EnergonRelics.CIRCUIT_BOARD_ITEM && !foundCircuit) {
|
||||
} else if (stack.getItem() == EnergonRelics.Items.CIRCUIT_BOARD && !foundCircuit) {
|
||||
foundCircuit = true;
|
||||
} else if (!stack.isEmpty()) {
|
||||
return false;
|
||||
@ -36,7 +36,7 @@ public class DuplicateNetworkChipRecipe extends SpecialCraftingRecipe {
|
||||
ItemStack out = ItemStack.EMPTY;
|
||||
for (int i = 0; i < inv.size(); i++) {
|
||||
ItemStack stack = inv.getStack(i);
|
||||
if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) {
|
||||
if (stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM) {
|
||||
out = stack.copy();
|
||||
out.setCount(1);
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class DuplicateNetworkChipRecipe extends SpecialCraftingRecipe {
|
||||
ItemStack stack = inv.getStack(i);
|
||||
if (stack.getItem().hasRecipeRemainder()) {
|
||||
defaultedList.set(i, new ItemStack(stack.getItem().getRecipeRemainder()));
|
||||
} else if (stack.getItem() == EnergonRelics.NETWORK_CHIP_ITEM) {
|
||||
} else if (stack.getItem() == EnergonRelics.Items.NETWORK_CHIP_ITEM) {
|
||||
ItemStack newStack = stack.copy();
|
||||
newStack.setCount(1);
|
||||
defaultedList.set(i, newStack);
|
||||
@ -69,6 +69,6 @@ public class DuplicateNetworkChipRecipe extends SpecialCraftingRecipe {
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return EnergonRelics.DUPLICATE_NETWORK_CHIP_RECIPE;
|
||||
return EnergonRelics.Extras.DUPLICATE_NETWORK_CHIP_RECIPE;
|
||||
}
|
||||
}
|
||||
|
@ -103,12 +103,14 @@ public final class InfuserRegistry {
|
||||
add(Items.GOLDEN_APPLE, new InfuserEntry(510, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.ENCHANTED_GOLDEN_APPLE)}, new InfuserAction[]{new InfuserAction.ExplosionAction()}));
|
||||
add(Items.COAL, new InfuserEntry(340, 0.2d, new InfuserAction[]{new InfuserAction.ItemAction(Items.DIAMOND)}, new InfuserAction[]{new InfuserAction.ExplosionAction()}));
|
||||
|
||||
add(EnergonRelics.VERIDIUM_INGOT_ITEM, new InfuserEntry(240, 0.25d, new InfuserAction[]{new InfuserAction.ItemAction(EnergonRelics.VERIDIUM_ORB_ITEM)}, new InfuserAction[]{new InfuserAction.ParticleAction(), new InfuserAction.ItemAction(EnergonRelics.VERIDIUM_POWDER_ITEM), new InfuserAction.ExplosionAction()}));
|
||||
add(EnergonRelics.Items.VERIDIUM_INGOT, new InfuserEntry(240, 0.25d, new InfuserAction[]{new InfuserAction.ItemAction(EnergonRelics.Items.VERIDIUM_ORB)}, new InfuserAction[]{new InfuserAction.ParticleAction(), new InfuserAction.ItemAction(EnergonRelics.Items.VERIDIUM_POWDER), new InfuserAction.ExplosionAction()}));
|
||||
|
||||
add(EnergonRelics.VERIDIUM_POWDER_ITEM, new InfuserEntry(170, 0.27d, new InfuserAction[]{new InfuserAction.ItemAction(new ItemStack(EnergonRelics.VERIDIUM_INGOT_ITEM, 2))}, new InfuserAction[]{new InfuserAction.ParticleAction(), new InfuserAction.ExplosionAction()}));
|
||||
add(EnergonRelics.Items.VERIDIUM_POWDER, new InfuserEntry(170, 0.27d, new InfuserAction[]{new InfuserAction.ItemAction(new ItemStack(EnergonRelics.Items.VERIDIUM_INGOT, 2))}, new InfuserAction[]{new InfuserAction.ParticleAction(), new InfuserAction.ExplosionAction()}));
|
||||
|
||||
add(Items.GOLD_NUGGET, new InfuserEntry(260, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.GOLD_INGOT)}, new InfuserAction[]{new InfuserAction.ItemAction(Items.IRON_NUGGET), new InfuserAction.ParticleAction()}));
|
||||
add(Items.IRON_NUGGET, new InfuserEntry(260, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.IRON_INGOT)}, new InfuserAction[]{new InfuserAction.ParticleAction()}));
|
||||
|
||||
add(Items.IRON_ORE, new InfuserEntry(270, 0.42d, new InfuserAction[]{new InfuserAction.ItemAction(Items.GOLD_ORE)}, new InfuserAction[]{new InfuserAction.ItemAction(Items.IRON_ORE), new InfuserAction.ItemAction(Items.STONE)}));
|
||||
}
|
||||
|
||||
private static Item[] getWool() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.thebrokenrail.energonrelics.block.entity.forcefield.laser;
|
||||
package com.thebrokenrail.energonrelics.registry.laser;
|
||||
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
@ -13,10 +13,19 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Industrial Laser Registry
|
||||
*/
|
||||
public class IndustrialLaserRegistry {
|
||||
private static final Map<Block, Function<Random, ItemStack>> map = new HashMap<>();
|
||||
|
||||
private static void add(Block ore, Item ingot, Block storage) {
|
||||
/**
|
||||
* Add To Registry
|
||||
* @param ore Ore Block
|
||||
* @param ingot Ingot Item
|
||||
* @param storage Storage Block
|
||||
*/
|
||||
public static void add(Block ore, Item ingot, Block storage) {
|
||||
map.put(ore, random -> {
|
||||
int min = HardcodedConfig.INDUSTRIAL_LASER_MIN_INGOTS_FROM_ORE;
|
||||
int max = HardcodedConfig.INDUSTRIAL_LASER_MAX_INGOTS_FROM_ORE;
|
||||
@ -25,14 +34,27 @@ public class IndustrialLaserRegistry {
|
||||
|
||||
return new ItemStack(ingot, count);
|
||||
});
|
||||
map.put(storage, random -> new ItemStack(ingot, HardcodedConfig.INDUSTRIAL_LASER_INGOTS_FROM_STORAGE));
|
||||
if (storage != null) {
|
||||
map.put(storage, random -> new ItemStack(ingot, HardcodedConfig.INDUSTRIAL_LASER_INGOTS_FROM_STORAGE));
|
||||
}
|
||||
}
|
||||
|
||||
static boolean has(Block block) {
|
||||
/**
|
||||
* Check If Registry Contains Block
|
||||
* @param block Block
|
||||
* @return If Registry Contains Block
|
||||
*/
|
||||
public static boolean has(Block block) {
|
||||
return map.containsKey(block);
|
||||
}
|
||||
|
||||
static ItemStack get(Block block, Random random) {
|
||||
/**
|
||||
* Get From Registry
|
||||
* @param block Block
|
||||
* @param random Random
|
||||
* @return Output Item(s)
|
||||
*/
|
||||
public static ItemStack get(Block block, Random random) {
|
||||
return map.get(block).apply(random);
|
||||
}
|
||||
|
||||
@ -42,8 +64,9 @@ public class IndustrialLaserRegistry {
|
||||
add(Blocks.COAL_ORE, Items.COAL, Blocks.COAL_BLOCK);
|
||||
add(Blocks.IRON_ORE, Items.IRON_INGOT, Blocks.IRON_BLOCK);
|
||||
add(Blocks.GOLD_ORE, Items.GOLD_INGOT, Blocks.GOLD_BLOCK);
|
||||
add(Blocks.NETHER_GOLD_ORE, Items.GOLD_INGOT, null);
|
||||
add(Blocks.DIAMOND_ORE, Items.DIAMOND, Blocks.DIAMOND_BLOCK);
|
||||
add(Blocks.EMERALD_ORE, Items.EMERALD, Blocks.EMERALD_BLOCK);
|
||||
add(EnergonRelics.VERIDIUM_ORE_BLOCK, EnergonRelics.VERIDIUM_INGOT_ITEM, EnergonRelics.VERIDIUM_BLOCK_BLOCK);
|
||||
add(EnergonRelics.Blocks.VERIDIUM_ORE, EnergonRelics.Items.VERIDIUM_INGOT, EnergonRelics.Blocks.VERIDIUM_BLOCK);
|
||||
}
|
||||
}
|
@ -43,8 +43,8 @@ public final class ReactorFuelRegistry {
|
||||
}
|
||||
|
||||
static {
|
||||
add(EnergonRelics.VERIDIUM_INGOT_ITEM, 1f);
|
||||
add(EnergonRelics.VERIDIUM_BLOCK_BLOCK.asItem(), 9f);
|
||||
add(EnergonRelics.VERIDIUM_POWDER_ITEM, 0.25f);
|
||||
add(EnergonRelics.Items.VERIDIUM_INGOT, 1f);
|
||||
add(EnergonRelics.Blocks.VERIDIUM_BLOCK.asItem(), 9f);
|
||||
add(EnergonRelics.Items.VERIDIUM_POWDER, 0.25f);
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public abstract class AbstractResearchComplexRoomPart extends BaseResearchComple
|
||||
|
||||
set(new BlockPos(0, 0, 2), plate);
|
||||
|
||||
BlockState light = EnergonRelics.ENERGON_LIGHT_BLOCK.getDefaultState();
|
||||
BlockState light = EnergonRelics.Blocks.ENERGON_LIGHT.getDefaultState();
|
||||
List<BlockPos> list = getLights();
|
||||
for (BlockPos pos : list) {
|
||||
set(pos, light);
|
||||
|
@ -17,7 +17,7 @@ public abstract class BaseResearchComplexPart extends StructurePart<ResearchComp
|
||||
|
||||
@Override
|
||||
protected void handleBlockPlace(World world, BlockPos pos, BlockState state) {
|
||||
if (state.getBlock() == EnergonRelics.ENERGON_LIGHT_BLOCK) {
|
||||
if (state.getBlock() == EnergonRelics.Blocks.ENERGON_LIGHT) {
|
||||
BlockEntity entity = world.getBlockEntity(pos);
|
||||
if (entity instanceof EnergonLightBlockEntity) {
|
||||
((EnergonLightBlockEntity) entity).toggle(getState().getMainNetwork());
|
||||
|
@ -62,7 +62,7 @@ public class ResearchComplexHallwayPart extends BaseResearchComplexPart {
|
||||
}
|
||||
|
||||
if (hasLight) {
|
||||
set(new BlockPos(3, 5, 1), EnergonRelics.ENERGON_LIGHT_BLOCK.getDefaultState());
|
||||
set(new BlockPos(3, 5, 1), EnergonRelics.Blocks.ENERGON_LIGHT.getDefaultState());
|
||||
}
|
||||
|
||||
if (leftRoomPadding == 0) {
|
||||
|
@ -74,19 +74,19 @@ public class ResearchComplexStartPart extends BaseResearchComplexPart {
|
||||
}
|
||||
|
||||
if (yOffset == 5) {
|
||||
set(new BlockPos(2, yOffset, 2), EnergonRelics.ENERGON_LIGHT_BLOCK.getDefaultState());
|
||||
set(new BlockPos(2, yOffset, 2), EnergonRelics.Blocks.ENERGON_LIGHT.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
private void buildReactor() {
|
||||
set(new BlockPos(0, 1, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
|
||||
set(new BlockPos(1, 2, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
|
||||
set(new BlockPos(0, 2, 0), EnergonRelics.REACTOR_CORE_BLOCK.getDefaultState());
|
||||
set(new BlockPos(-1, 2, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
|
||||
set(new BlockPos(0, 3, 0), EnergonRelics.REACTOR_INPUT_BLOCK.getDefaultState());
|
||||
set(new BlockPos(0, 2, -1), EnergonRelics.REACTOR_CONTROLLER_BLOCK.getDefaultState());
|
||||
set(new BlockPos(0, 1, 0), EnergonRelics.Blocks.THERMAL_CASING.getDefaultState());
|
||||
set(new BlockPos(1, 2, 0), EnergonRelics.Blocks.THERMAL_CASING.getDefaultState());
|
||||
set(new BlockPos(0, 2, 0), EnergonRelics.Blocks.REACTOR_CORE.getDefaultState());
|
||||
set(new BlockPos(-1, 2, 0), EnergonRelics.Blocks.THERMAL_CASING.getDefaultState());
|
||||
set(new BlockPos(0, 3, 0), EnergonRelics.Blocks.REACTOR_INPUT.getDefaultState());
|
||||
set(new BlockPos(0, 2, -1), EnergonRelics.Blocks.REACTOR_CONTROLLER.getDefaultState());
|
||||
set(new BlockPos(0, 1, -1), Blocks.LEVER.getDefaultState().with(LeverBlock.FACE, WallMountLocation.FLOOR));
|
||||
set(new BlockPos(0, 2, 1), EnergonRelics.THERMAL_GLASS_BLOCK.getDefaultState());
|
||||
set(new BlockPos(0, 2, 1), EnergonRelics.Blocks.THERMAL_GLASS.getDefaultState());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -105,10 +105,10 @@ public class ResearchComplexStartPart extends BaseResearchComplexPart {
|
||||
@Override
|
||||
protected void handleBlockPlace(World world, BlockPos pos, BlockState state) {
|
||||
super.handleBlockPlace(world, pos, state);
|
||||
if (state.getBlock() == EnergonRelics.REACTOR_CONTROLLER_BLOCK) {
|
||||
if (state.getBlock() == EnergonRelics.Blocks.REACTOR_CONTROLLER) {
|
||||
BlockEntity entity = world.getBlockEntity(pos);
|
||||
if (entity instanceof ReactorControllerBlockEntity) {
|
||||
((ReactorControllerBlockEntity) entity).placeStack(EnergonRelics.NETWORK_CHIP_ITEM.create(getState().getMainNetwork()), world);
|
||||
((ReactorControllerBlockEntity) entity).placeStack(EnergonRelics.Items.NETWORK_CHIP_ITEM.create(getState().getMainNetwork()), world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,11 @@ package com.thebrokenrail.energonrelics.util;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class BooleanIterator {
|
||||
public static void run(Consumer<Boolean> function) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"parent": "minecraft:block/block",
|
||||
"textures": {
|
||||
"0": "energonrelics:block/gold_block",
|
||||
"0": "minecraft:block/gold_block",
|
||||
"1": "energonrelics:block/lightning_rod_base",
|
||||
"particle": "#1"
|
||||
},
|
||||
@ -53,8 +53,7 @@
|
||||
"east": {"uv": [4, 3, 16, 5], "texture": "#1"},
|
||||
"south": {"uv": [2, 2, 14, 4], "rotation": 180, "texture": "#1"},
|
||||
"west": {"uv": [4, 3, 16, 5], "texture": "#1"},
|
||||
"up": {"uv": [2, 2, 14, 14], "texture": "#1"},
|
||||
"down": {"uv": [0, 0, 12, 12], "texture": "#missing"}
|
||||
"up": {"uv": [2, 2, 14, 14], "texture": "#1"}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
"credit": "Made by Azazelthedemonlord",
|
||||
"textures": {
|
||||
"0": "energonrelics:block/lightning_rod",
|
||||
"particle": "energonrelics:block/gold_block"
|
||||
"particle": "minecraft:block/gold_block"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
"textures": {
|
||||
"0": "energonrelics:block/lightning_rod",
|
||||
"1": "energonrelics:block/lightning_rod_base",
|
||||
"particle": "energonrelics:block/gold_block"
|
||||
"particle": "minecraft:block/gold_block"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
@ -37,9 +37,7 @@
|
||||
"to": [9, 12, 11],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [15, 19, 20]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 2, 1], "texture": "#missing"},
|
||||
"east": {"uv": [1, 7, 2, 13], "rotation": 270, "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 2, 1], "texture": "#missing"},
|
||||
"west": {"uv": [1, 7, 2, 13], "rotation": 270, "texture": "#0"},
|
||||
"up": {"uv": [1, 2, 3, 8], "texture": "#0"},
|
||||
"down": {"uv": [1, 8, 3, 14], "texture": "#0"}
|
||||
|
Before Width: | Height: | Size: 416 B |
After Width: | Height: | Size: 502 B |
After Width: | Height: | Size: 497 B |
After Width: | Height: | Size: 508 B |
After Width: | Height: | Size: 509 B |
After Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 526 B After Width: | Height: | Size: 526 B |
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 518 B |
After Width: | Height: | Size: 403 B |
After Width: | Height: | Size: 363 B |
After Width: | Height: | Size: 708 B |
After Width: | Height: | Size: 23 KiB |
@ -0,0 +1,3 @@
|
||||
{
|
||||
"animation": {}
|
||||
}
|
After Width: | Height: | Size: 728 B |
After Width: | Height: | Size: 793 B |
After Width: | Height: | Size: 618 B |
After Width: | Height: | Size: 858 B |
After Width: | Height: | Size: 912 B |
After Width: | Height: | Size: 863 B |
After Width: | Height: | Size: 804 B |
After Width: | Height: | Size: 779 B |
After Width: | Height: | Size: 1009 B |
After Width: | Height: | Size: 1.0 KiB |